QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131344 | #4934. Forbidden Card | arnold518 | WA | 8ms | 13328kb | C++17 | 858b | 2023-07-26 23:24:46 | 2023-07-26 23:24:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e6;
int N, M;
pii A[MAXN+10];
int B[MAXN+10], chk[MAXN+10];
int dp[MAXN+10], ans[MAXN+10];
int main()
{
scanf("%d%d", &N, &M);
for(int i=1; i<=N; i++) scanf("%d%d", &A[i].first, &A[i].second);
for(int i=1; i<=N; i++) A[N+i]=A[i];
A[N+N+1]=A[1];
int pos;
for(int i=1; i<=N+N+1; i++)
{
if(!chk[A[i].first]) B[i]=A[i].first;
else if(!chk[A[i].second]) B[i]=A[i].second;
else { pos=i; break; }
chk[B[i]]=i;
}
for(int i=pos-1; i>=1; i--)
{
if(B[i]==A[i].second) dp[i]=i;
else
{
if(chk[A[i].second]==0) dp[i]=pos;
else dp[i]=dp[chk[A[i].second]];
}
ans[dp[i]%N]++; M--;
}
ans[pos%N]+=M;
for(int i=1; i<=N; i++) printf("%d\n", ans[i%N]);
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 7844kb
input:
3 6 1 2 2 4 4 2
output:
3 0 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 9816kb
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: 2ms
memory: 9800kb
input:
1 2 1 2
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 8ms
memory: 13328kb
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:
197458 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 371st lines differ - expected: '1', found: '0'