标签:++ int sig space max air cond cpp etl
最后一个点T,不知道怎么优化比较好。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
const int inf = 0x3f3f3f3f;
const int maxn = 2000+10;
int t, n;
vector<string> op[10000+10];
int id[10000+10];
int sz[10000+10];
bool check(){
for(int i=0; i<n; i++){
if(id[i]<sz[i]) return false;
}
return true;
}
int get(string s){
int num = 0;
for(int i=1; i<s.length(); i++){
num = num*10 + s[i]-'0';
}
return num;
}
int main(){
string temp;
getline(cin, temp);
stringstream s1(temp);
s1>>t;
s1>>n;
for(int i=0; i<n; i++) op[i].resize(10);
while(t--){
for(int i=0; i<n; i++) {
getline(cin, temp);
stringstream ss(temp);
int idx = 0;
while(ss>>op[i][idx++]){
//cout<<"-"<<op[i][idx-1]<<">";
}
sz[i] = idx-1;
}
// for(int i=0; i<n; i++){
// for(int j=0; j<sz[i]; j++){
// cout<<op[i][j]<<" ";
// }
// cout<<endl;
// }
for(int i=0 ;i<n; i++) id[i] = 0;
bool can = false;
while(true){
if(check()) {
can = true;
break;
}
bool you = false;
for(int i=0; i<n; i++){
if(id[i]>=sz[i]) continue;
if(op[i][id[i]][0] == 'S'){
int dst = get(op[i][id[i]]);
if(id[dst]>=sz[dst]) continue;
int temp1 = get(op[dst][id[dst]]);
if(op[dst][id[dst]][0] == 'R'&&temp1 == i){
id[i]++;
id[dst]++;
you = true;
break;
}
}
}
if(!you){
break;
}
}
if(can) cout<<0<<endl;
else cout<<1<<endl;
}
return 0;
}
/*
3 2
R1 S1
S0 R0
R1 S1
R0 S0
R1 R1 R1 R1 S1 S1 S1 S1
S0 S0 S0 S0 R0 R0 R0 R0
2 3
R1 S1
R2 S0 R0 S2
S1 R1
R1
R2 S0 R0
S1 R1
*/
标签:++ int sig space max air cond cpp etl
原文地址:https://www.cnblogs.com/babydragon/p/11495104.html