# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
794948 | 2023-07-27T04:23:03 Z | vjudge1 | Comparing Plants (IOI20_plants) | C++17 | 1 ms | 212 KB |
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define N 200100 #define n R.size() int pos[N], cnt; deque<int> R; int info[200100][3]; void init2(int k, vector<int> r) { R.resize(r.size()); iota(R.begin(), R.end(), 0); for(int i = 0; i < n; i++) if(r[R[0]] == r[R[n-1]]) R.push_back(R[0]),R.pop_front(), info[i][2] = 1; else break; info[R[0]][0] = 1; info[R[0]][1] = r[R[0]]; for(int i = 1; i < n; i++) { info[R[i]][1] = r[R[i]]; if(r[R[i]]!=r[R[i-1]]) { info[R[i]][0] = ++cnt; } else { info[R[i]][0] = info[R[i-1]][0]; } } return; } void init(int k, vector<int> r) { init2(k,r); } int compare_plants(int x, int y) { bool a = info[x][0] == info[y?y-1:n-1][0], b = info[x?x-1:n-1][0]==info[y][0]; if(!a&&!b) return 0; if(b) swap(x,y); int ans = (info[x][1]^info[x][2]^x>y); return (b^ans?1:-1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Incorrect | 1 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |