# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120013 | 2019-06-23T02:15:05 Z | E869120 | Editor (BOI15_edi) | C++14 | 3000 ms | 32080 KB |
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; #pragma warning (disable: 4996) int N, A[1 << 19], G[1 << 19], level[1 << 19], par[1 << 19], maxlevel = 0; vector<int>I[1 << 19]; set<int>Set; int main() { scanf("%d", &N); for (int i = 1; i <= N; i++) { scanf("%d", &A[i]); level[i] = max(0, -A[i]); maxlevel = max(maxlevel, level[i]); I[level[i]].push_back(i); } for (int i = 1; i <= N; i++) Set.insert(i); for (int i = maxlevel; i >= 1; i--) { set<int>Set2; for (int j = 0; j < I[i].size(); j++) { auto itr = Set.lower_bound(I[i][j]); if (itr != Set.end() && (*itr) == I[i][j]) { Set.erase(I[i][j]); Set2.insert(I[i][j]); } } for (int j = 0; j < I[i].size(); j++) { auto itr = Set.lower_bound(I[i][j]); itr--; par[I[i][j]] = (*itr); auto itr2 = Set2.lower_bound(I[i][j]); if (itr2 != Set2.end() && (*itr2) == I[i][j]) Set.erase(par[I[i][j]]); } } for (int i = 1; i <= N; i++) { if (A[i] > 0) { G[i] = 1; } else { G[i] = 1; int cx = i; while (par[cx] != 0) { cx = par[cx]; G[cx] ^= 1; } } int ans = 0; for (int j = 1; j <= i; j++) { if (A[j] > 0 && G[j] == 1) ans = j; } printf("%d\n", A[ans]); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 12672 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3041 ms | 32080 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3048 ms | 24424 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 12672 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |