QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235797#6601. Mean Streets of Gadgetzanwhsyhyyh#WA 1ms9920kbC++142.3kb2023-11-03 09:40:282023-11-03 09:40:28

Judging History

你现在查看的是最新测评结果

  • [2023-11-03 09:40:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9920kb
  • [2023-11-03 09:40:28]
  • 提交

answer

#include<bits/stdc++.h>
#define N 4000010
#define rep(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
int rd() {
    int res=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f*=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^48),ch=getchar();
    return res*f;
}
int n,m,ans[N];
int h[N],Cnt;
struct edge {
    int to,nxt,w;
}e[N];
void add(int u,int v,int w) {
//cout<<u<<' '<<v<<' '<<w<<endl;
    e[++Cnt]=(edge) {v,h[u],w};
    h[u]=Cnt;
}
char ch[N];
queue<int>qu;
int st[N],top;
int cnt[N];
void check(int x,int w) {
    if(ans[x]&w) return ;
    ans[x]|=w;
    if(ans[x]==3) {
        printf("conflict");
        exit(0);
    }
    qu.push(x);
}
void bfs() {
    int x;
    while(!qu.empty()) {
        x=qu.front(),qu.pop();
//        cout<<"FUCK "<<x<<" "<<ans[x]<<endl;
        for(int i=h[x],v;i;i=e[i].nxt) {
            v=e[i].to;
            if(ans[x]==1) {
                cnt[abs(e[i].w)]--;
                if(cnt[abs(e[i].w)]==0) check(v,(e[i].w>0)?1:2);
            }
        }
    }
}
int main() {
    scanf("%d%d",&n,&m);ch[0]=getchar();ch[0]=getchar();
    rep(i,1,n) {
        int j=0;int  flag=0;
        while(1) {
            ch[++j]=getchar();
            flag|=ch[j]=='-';
            if(ch[j]==EOF||ch[j]=='\n') break;
        }
        j--;
        if(ch[1]=='!') {
            int res=0;
            rep(k,2,j) if(ch[k]>='0'&&ch[k]<='9') res=(res<<1)+(res<<3)+(ch[k]^48);
            check(res,2);
            continue;
        }
        if(!flag) {
            int res=0;
            rep(k,1,j) if(ch[k]>='0'&&ch[k]<='9') res=(res<<1)+(res<<3)+(ch[k]^48);
            check(res,1);
            continue;
        }
        int k=0;
        top=0;
        while(1) {
            int res=0;
            while(ch[k+1]>='0'&&ch[k+1]<='9') k++,res=(res<<1)+(res<<3)+(ch[k]^48);
            st[++top]=res;
            k++;
            if(ch[k+1]=='-') break;
        }
        k+=3;
        flag=(ch[k+1]=='!')?-1:1;
if(ch[k+1]=='!') k++;
        int res=0;
        while(ch[k+1]>='0'&&ch[k+1]<='9') k++,res=(res<<1)+(res<<3)+(ch[k]^48);
        rep(l,1,top) add(st[l],res,i*flag);
        cnt[i]=top;
    }
    bfs();
    rep(i,1,m) if(ans[i]==1) printf("T");else printf("F");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 9920kb

input:

3 3
!1
2 -> 1
1 2 -> !3

output:

TFF

result:

wrong answer participant found wrong solution