QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#859127 | #9677. 基础博弈练习题 | lgvc# | 0 | 15ms | 16244kb | C++23 | 2.1kb | 2025-01-17 15:35:44 | 2025-01-17 15:35:44 |
Judging History
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],vi[1000009],v2[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(as[to[i]]==y&&(!v2[to[i]])) {
v2[to[i]]=1;
rs2(to[i],y);
} else if(as[to[i]]==y-1&&(vi[to[i]]==0)) {
vi[to[i]]=1;
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;
}
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);
}
}
}
bool la=0;
for(int i=Q;i>=1;i--) {
bool ff=0;
for(int j=0;j<t[c[i]].size();j++) {
int x=t[c[i]][j];
if(as[x]<i-1) continue;
if((as[x]>i)||(as[x]==i&&v2[x]==0)||(as[x]==i-1&&vi[x]==0)) {
rs2(x,i-1),ff=1;
}
}
la=ff;
}
for(int i=1;i<=N;i++) {
int aq=as[i];
if((aq!=-1)&&vi[i]) aq++;
printf("%d ",aq);
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 14160kb
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:
0 -1 -1 -1 2 0 -1 7 0 -1 3 -1 0 0 1 -1 0 -1 0 0 -1 0 -1 2 -1 -1 -1 -1 -1 -1 0 0 0 -1 0 -1 3 0 0 0 0 0 -1 -1 -1 -1 0 0 0 -1 0 0 3 0 0 0 -1 -1 3 -1 0 0 0 0 0 8 -1 -1 1 -1 -1 0 3 4 -1 3 -1 3 -1 0 0 0 -1
result:
ok 83 numbers
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 14164kb
input:
95 33 40 1 1 1 1 3 3 1 1 2 1 1 2 3 3 2 2 2 1 2 3 1 2 1 2 2 1 2 2 3 3 1 1 2 3 1 2 1 3 2 1 1 1 3 2 1 1 1 2 3 2 3 1 1 3 2 3 1 2 1 3 1 2 1 1 1 1 2 1 2 3 1 1 3 3 2 1 3 3 3 1 2 3 1 2 2 1 3 2 1 1 1 2 2 3 1 2 2 3 1 3 3 2 3 3 2 2 2 2 1 1 1 1 2 1 1 1 1 1 2 3 1 3 2 2 3 1 3 3 1 2 2 3 2 1 3 11 95 57 80 22 89 56 ...
output:
2 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 3 -1 -1 -1 -1 -1 -1 -1 3 -1 3 -1 -1 0 -1 3 3 -1 1 0 -1 2 -1 -1 0 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 1 -1 -1 2 -1 -1 -1 3 3 -1 -1 -1 0 -1 -1 -1 -1 2 -1 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 3 -1 -1 -1 -1 -1 -1 3 0 -1 -1 -1 -1 2 -1 0 1
result:
wrong answer 11th 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: 15ms
memory: 16244kb
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%