QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#859077#9677. 基础博弈练习题lgvc#0 17ms22540kbC++231.9kb2025-01-17 14:42:242025-01-17 14:42:24

Judging History

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

  • [2025-01-17 14:42:24]
  • 评测
  • 测评结果:0
  • 用时:17ms
  • 内存:22540kb
  • [2025-01-17 14:42:24]
  • 提交

answer

#include <bits/stdc++.h>
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
    if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
    *pp++=ch;
}
inline void pcc(){
    fwrite(buf2,1,pp-buf2,stdout);
    pp=buf2;
}
inline int read(void){
    int w=1;
    register int x(0);register char c(getchar());
    while(c<'0'||c>'9'){if(c=='-') w=-1;c=getchar();}
    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return w*x;
}
int N,M,Q,a[1000009],hd[1000009],to[2200009],nxt[2200009],k,
as[1000009],c[1000009],ra[1000009];
void rs(int x,int y) {
    for(int i=hd[x];i;i=nxt[i]) {
        if(as[to[i]]==-1) {
            as[to[i]]=y;
            rs(to[i],y);
        }
    }
}
void rs2(int x,int y) {
    for(int i=hd[x];i;i=nxt[i]) {
        if(ra[to[i]]==-1&&(abs(y-as[to[i]])<=1)) {
            ra[to[i]]=y;
            rs2(to[i],y);
        }
    }
}
void l(int u,int v) {
    to[++k]=v;nxt[k]=hd[u];hd[u]=k;
}
std::vector<int> t[1000009];
signed main(void) {
    N=read();M=read();Q=read();
    for(int i=1;i<=N;i++) {
        a[i]=read();
        t[a[i]].push_back(i);
        as[i]=-1;
        ra[i]=-1;
    }
    for(int i=1;i<=Q;i++) {
        c[i]=read();
    }
    for(int i=1;i<=M;i++) {
        int u=read(),v=read();
        l(v,u);
    }
    for(int i=1;i<=Q;i++) {
        for(int j=0;j<t[c[i]].size();j++) {
            if(as[t[c[i]][j]]==-1) {
                rs(t[c[i]][j],i-1);
            }
        }
    }
    for(int i=Q;i>=1;i--) {
        for(int j=0;j<t[c[i]].size();j++) {
            int x=t[c[i]][j];
            if(ra[x]==i||as[x]==-1) {
                rs2(x,i-1);
            }
        }
    }
    for(int i=1;i<=N;i++) printf("%d ",ra[i]);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 16204kb

input:

83 93 13
8 9 10 7 7 7 6 3 1 10 6 2 5 7 1 3 4 2 1 10 7 4 8 9 2 2 1 9 2 5 1 7 8 6 1 9 9 10 4 1 2 9 2 3 4 2 9 10 8 1 4 1 8 4 1 4 4 7 4 8 2 9 2 5 2 2 3 3 8 5 2 9 3 10 8 8 1 6 6 1 6 7 10
7 5 10 3 2 2 7 4 8 7 6 6 5
56 36
33 41
32 62
37 7
6 53
41 13
9 36
44 77
38 62
76 16
72 5
40 13
55 60
5 78
72 45
13 44
...

output:

1 -1 -1 -1 3 1 -1 7 1 -1 3 -1 1 1 1 -1 1 -1 1 1 -1 1 -1 2 -1 -1 -1 -1 -1 -1 1 1 1 -1 1 -1 3 1 1 1 1 1 -1 -1 -1 -1 1 1 1 -1 1 1 4 1 1 1 -1 -1 3 -1 1 1 1 1 1 8 -1 -1 1 -1 -1 -1 4 5 -1 4 -1 3 -1 1 1 1 -1 

result:

wrong answer 1st numbers differ - expected: '0', found: '1'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 17ms
memory: 22540kb

input:

100000 355071 10000
5 7 4 7 4 1 10 5 9 4 9 4 3 10 5 4 9 1 7 10 1 6 10 3 10 9 8 4 6 3 10 8 6 8 3 5 10 9 7 7 1 3 8 8 6 2 8 4 2 9 1 10 3 6 3 8 9 10 5 7 3 2 1 5 7 4 3 4 6 4 2 7 2 5 5 6 4 6 7 4 4 6 4 2 3 9 9 9 10 8 1 6 7 2 9 8 2 3 1 6 9 4 10 3 10 1 2 3 3 4 1 1 1 5 8 6 8 3 1 6 2 9 5 9 4 7 2 10 7 5 2 2 7 4...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1...

result:

wrong answer 1st numbers differ - expected: '0', found: '1'

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%