QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149952 | #4934. Forbidden Card | MegaSam | Compile Error | / | / | C++14 | 1.4kb | 2023-08-25 14:40:12 | 2023-08-25 14:40:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 5;
const int M = 1000000 + 5;
int N, M, a[N], b[N];
int simul[N << 1], tot;
char vis[M], cardTy[N];
int lp[M], ep[N << 1], ans[N];
int main() {
// freopen("marketplace.in", "r", stdin);
// freopen("marketplace.out", "w", stdout);
scanf("%d%d", &N, &M);
for (int i = 1; i <= N; i ++) {
scanf("%d%d", a + i, b + i);
if (tot == i - 1) {
if (!vis[a[i]]) {
vis[a[i]] = 1;
simul[++ tot] = a[i];
}else if (!vis[b[i]]) {
vis[b[i]] = 1;
simul[++ tot] = b[i];
cardTy[i] = 1;
}
}
}
if (tot == N) {
for (int i = 1; i <= N; i ++) {
if (cardTy[i] || vis[b[i]]) {
break;
}
vis[b[i]] = 1;
simul[++ tot] = b[i];
}
}
for (int i = tot; i > 0; i --) {
lp[simul[i]] = i;
if (i > N || cardTy[i] || vis[b[i]]) {
ans[i > N ? i - N : i] ++;
ep[i] = i > N ? i - N : i;
}else {
ep[i] = ep[lp[b[i]]];
int p = ep[i];
ans[p] ++;
}
vis[simul[i]] = 0;
}
ans[tot % N + 1] += ans[0] + M - tot;
for (int i = 1; i <= N; i ++) printf("%d\n", ans[i]);
}
詳細信息
answer.code:6:5: error: conflicting declaration ‘int N’ 6 | int N, M, a[N], b[N]; | ^ answer.code:4:11: note: previous declaration as ‘const int N’ 4 | const int N = 100000 + 5; | ^ answer.code:6:8: error: conflicting declaration ‘int M’ 6 | int N, M, a[N], b[N]; | ^ answer.code:5:11: note: previous declaration as ‘const int M’ 5 | const int M = 1000000 + 5; | ^ answer.code: In function ‘int main()’: answer.code:13:10: warning: writing into constant object (argument 2) [-Wformat=] 13 | scanf("%d%d", &N, &M); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:13:10: warning: writing into constant object (argument 3) [-Wformat=] answer.code:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] answer.code:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%d%d", a + i, b + i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~