QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150778 | #4934. Forbidden Card | KAxdd | WA | 37ms | 41672kb | C++14 | 1.1kb | 2023-08-26 09:48:34 | 2023-08-26 09:48:37 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int a[100005],b[100005],ans[100005];
int n,m,live[1000005],to[1000005],cnt,tot,v[1000005],num,talk[1000005];
vector<int> vis[1000005];
void dfs(int x) {
tot++;cnt=0;
int flag=0;
if(x==n+1) x=1;
int len=vis[a[x]].size();
for(int i=0;i<len;i++) {
int u=vis[a[x]][i];
if(!live[u]) {
to[u]=tot,v[++cnt]=u;
if(!u) {
flag++;
}
}
}
if(!flag) vis[a[x]].push_back(0),talk[a[x]]++;
len=vis[b[x]].size();
for(int i=0;i<len;i++) {
int u=vis[b[x]][i];
if(!live[u] && to[u]==tot) {
if(u==0) {
ans[x]+=m-num;
return ;
}
num++; ans[x]++; live[u]=true;
}
}
for(int i=1;i<=cnt;i++) {
if(!live[v[i]]) {
vis[b[x]].push_back(v[i]);
if(!v[i]) talk[b[x]]++;
}
}
if(!flag && !live[a[x]] && talk[b[x]]) num++,ans[x]++,live[a[x]]=true;
if(flag && !live[b[x]] && talk[a[x]]) num++,ans[x]++,live[b[x]]=true;
dfs(x+1);
}
int main() {
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d %d",&a[i],&b[i]);
for(int i=1;i<=m;i++) vis[i].push_back(i);
dfs(1);
for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 32640kb
input:
3 6 1 2 2 4 4 2
output:
3 0 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 6ms
memory: 29768kb
input:
4 10 1 5 2 6 3 7 4 8
output:
4 2 2 2
result:
ok 4 lines
Test #3:
score: 0
Accepted
time: 0ms
memory: 33456kb
input:
1 2 1 2
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 37ms
memory: 41672kb
input:
69332 250102 51362 228823 206751 31351 181790 44202 186695 92215 172072 173179 86663 76959 42382 25827 204750 30001 42502 11959 201030 71886 227497 216114 164282 235028 178967 181951 125356 20611 169528 174071 50985 175562 63676 208400 189134 229462 49746 131529 180236 247427 29278 229589 30381 4412...
output:
217977 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 1st lines differ - expected: '197458', found: '217977'