mikechu @ 2020-05-23 15:26:31
rt,
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll t,n,m,dfn[2010],low[2010],cnt,num,tjvis[210];
ll h[2010];
vector<ll> g[2010];
stack<ll> st;
bool ist[2010];
void tarjan(ll u){
//printf("tarjan %lld %lld start\n",u,fa);
dfn[u] = low[u] = ++cnt;
st.push(u);
ist[u]=1;
for(ll i=0;i<g[u].size();i++){
ll v = g[u][i];
if(!dfn[v])tarjan(v),low[u] = min(low[u],low[v]);
else if(ist[i])low[u] = min(low[u],dfn[v]);
}
//printf("low[%lld] = %lld,dfn[%lld] = %lld\n",u,low[u],u,dfn[u]);
if(low[u] == dfn[u]){
num++;
ll i;
while(1){
i = st.top();
//h[num].push_back(i);
h[i] = num;
//printf("h[%lld].push_back(%lld)\n",num,i);
ist[i] = 0;
st.pop();
if(i == u)break;
}
}
//printf("tarjan %lld %lld over\n",u,fa);
}
int main(){
cin >> t;
while(t--){
cin >> n >> m;
for(ll i=1;i<=2009;i++)g[i].clear();
memset(h,0,sizeof(h));
memset(dfn,0,sizeof(dfn));
memset(low,0,sizeof(low));
memset(ist,0,sizeof(ist));
cnt=0;num=0;
while(!st.empty())st.pop();
for(ll s1,s2,i=1;i<=m;i++){
char c1,c2;bool f1,f2;
c1=0;
while(c1 != 'm' && c1 != 'h')c1 = getchar();
//scanf("%c%lld %c%lld",c1,s1,c2,s2);
cin >> s1;
getchar();c2 = getchar();
cin >> s2;
printf("c1 = %c,s1 = %lld,c2 = %c,s2 = %lld\n",c1,s1,c2,s2);
if(c1 == 'm')f1 = 0;
else f1 = 1;
if(c2 == 'm')f2 = 0;
else f2 = 1;
g[!f1 * n + s1].push_back(f2 * n + s2);
g[!f2 * n + s2].push_back(f1 * n + s1);
printf("join %lld to %lld,%lld to %lld\n",!f1*n+s1,f2*n+s2,!f2 * n + s2,f1 * n + s1);
}
for(ll i=1;i<=n*2;i++){
if(!dfn[i])tarjan(i);
}
bool f=0;
for(ll i=1;i<=n;i++){
if(h[i] == h[i+n])f=1;
}
if(f == 1){
cout << "BAD\n";
}
else cout << "GOOD\n";
}
}
by mikechu @ 2020-05-23 15:27:42
我要说的事,你们千万别@管理。
我刚才,滥用评测资源了
一直AC不了啊,
by xiaowangqianyue @ 2020-05-23 15:28:58
这个算滥用评测资源吗我谔谔那我完了
by mikechu @ 2020-05-23 15:30:09
好吧没事的我不误导萌新了
by mikechu @ 2020-05-25 23:06:14
好吧,两天的静态调试过后,我找到了:ins[v]写成了ins[i]。