QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#150498 | #4934. Forbidden Card | zqs | Compile Error | / | / | C++14 | 1.3kb | 2023-08-25 18:18:04 | 2023-08-25 18:18:05 |
Judging History
answer
#include <cstdio>
#include <cstring>
int lst[1000005], a[1000005], b[1000005], choice[1000005], lst2[1000005], ans[1000005];
bool mark[1000005], bchosen[1000005];
int main() {
int n, m, N = 0, lst1 = 0; scanf("%d%d", &n, &m), N = n;
for (int i = 1; i <= n; ++ i) scanf("%d%d", a + i, b + i);
for (int i = 1; i <= n; ++ i) {
bchosen[i] = mark[b[i]];
if (!mark[a[i]]) choice[i] = 0, mark[a[i]] = true;
else if (!mark[b[i]]) choice[i] = 1, mark[b[i]] = true;
else {N = i - 1; break;}
}
for (int i = N; i; -- i)
if (choice[i] == 0) lst[a[i]] = ((lst[b[i]] && !bchosen[i]) ? lst[b[i]] : i);
else lst[b[i]] = i;
if (N == n) {
lst1 = 0; while (lst1 < n && choice[lst1 + 1] == 0) ++ lst1;
while (lst2[0] < lst1 && !mark[b[lst2[0] + 1]]) mark[b[++ lst2[0]]] = true;
if (lst2[0] == n) lst2[0] = 1;
else ++ lst2[0];
for (int i = 1; i <= m; ++ i) lst2[i] = lst2[0];
for (int i = lst2[0] == 1 ? n : lst2[0] - 1; i; -- i) lst2[b[i]] = i;
}
for (int i = 1; i <= m; ++ i) {
int x = lst[i];
if (x && (choice[x] == 1 || (choice[x] == 0 && bchosen[x])) ++ ans[x];
else if (x && choice[x] == 0) ++ ans[N == n ? lst2[b[x]] : N + 1];
else if (N != n) ++ ans[N + 1];
else ++ ans[lst2[i]];
}
for (int i = 1; i <= n; ++ i) printf("%d\n", ans[i]);
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:29:21: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ 29 | if (x && (choice[x] == 1 || (choice[x] == 0 && bchosen[x])) ++ ans[x]; | ^ answer.code:29:42: error: lvalue required as increment operand 29 | if (x && (choice[x] == 1 || (choice[x] == 0 && bchosen[x])) ++ ans[x]; | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:30:17: error: expected primary-expression before ‘else’ 30 | else if (x && choice[x] == 0) ++ ans[N == n ? lst2[b[x]] : N + 1]; | ^~~~ answer.code:29:87: error: expected ‘)’ before ‘else’ 29 | if (x && (choice[x] == 1 || (choice[x] == 0 && bchosen[x])) ++ ans[x]; | ~ ^ | ) 30 | else if (x && choice[x] == 0) ++ ans[N == n ? lst2[b[x]] : N + 1]; | ~~~~ answer.code:8:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n, m, N = 0, lst1 = 0; scanf("%d%d", &n, &m), N = n; | ~~~~~^~~~~~~~~~~~~~~~ answer.code:9:44: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | for (int i = 1; i <= n; ++ i) scanf("%d%d", a + i, b + i); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~