题目有毒

P4171 [JSOI2010] 满汉全席

[看看帮助中的常见“我在本地/xxOJ AC了、洛谷却不过”的原因](//www.luogu.org/wiki/show?name=%E5%B8%AE%E5%8A%A9)
by 温情 @ 2018-05-17 20:31:59


@[温情](/space/show?uid=52603) 这跟“本地AC,洛谷WA”有关系吗 我是读入的问题啊
by 123456seh2 @ 2018-05-17 20:36:17


@[123456seh2](/space/show?uid=31831) 您没有贴代码,我也不知道您是用什么语言什么字符串读入的. C中的gets还是C++的getline? 这样的字符串读入在linux评测机下是会产生一些问题的. 具体什么问题我太蒻了不知道. 但是记住一点就好了,尽量尽量不要使用上面说的那两个读入就好了.可能会蜜汁WA. ~~(逃~~
by 温情 @ 2018-05-17 20:40:16


``` // luogu-judger-enable-o2 #include<bits/stdc++.h> #define min(a,b) (a<b)?a:b #define N 10010 using namespace std; struct edge{int ne,to;}e[N<<2]; int t,n,m,x,y,head[N],opt1,opt2,esum,ans; int scc,cnt,top,vis[N],bel[N],dfn[N],low[N],sta[N]; char s1[10],s2[10]; void add(int x,int y){ e[++esum]=(edge){head[x],y}; head[x]=esum; } void tarjan(int x){ dfn[x]=low[x]=++cnt,sta[++top]=x,vis[x]=1; for(int i=head[x];i;i=e[i].ne){ int v=e[i].to; if (!dfn[v]) { tarjan(v); low[x]=min(low[x],low[v]); }else if(vis[v]) low[x]=min(low[x],dfn[v]); } if(dfn[x]==low[x]){ scc++; do{ bel[sta[top]]=scc; vis[sta[top]]=0; }while(sta[top--]!=x); } } int main(){ scanf("%d",&t); while(t--){ scanf("%d%d",&n,&m); top=cnt=esum=ans=scc=0; memset(head,0,sizeof(head)); memset(vis,0,sizeof(vis)); memset(dfn,0,sizeof(dfn)); memset(low,0,sizeof(low)); for(int i=1;i<=m;i++){ scanf("%s%s",s1,s2); if (s1[0]=='m') opt1=0;else opt1=1; if (s2[0]=='m') opt2=0;else opt2=1; add((s1[1]^48)*2-(!opt1),(s2[1]^48)*2-opt2); add((s2[1]^48)*2-(!opt2),(s1[1]^48)*2-opt1); } for(int i=1;i<=(n<<1);i++) if (!dfn[i]) tarjan(i); for(int i=1;i<=n;i++) if (bel[2*i-1]==bel[2*i]) ans++; if (!ans) printf("GOOD\n"); else printf("BAD\n"); } return 0; } ```
by 123456seh2 @ 2018-05-17 20:41:15


@[温情](/space/show?uid=52603) 我后来把那个字符串读入改成逐字符就过了
by 123456seh2 @ 2018-05-17 20:42:50


|