Submission #823669

#TimeUsernameProblemLanguageResultExecution timeMemory
823669GusterGoose27Comparing Plants (IOI20_plants)C++17
5 / 100
85 ms6380 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+5; bool lt[MAXN]; int pre[2*MAXN]; int n; void init(int k, vector<int> r) { n = r.size(); for (int i = 0; i < n; i++) { lt[i] = r[i]; } for (int i = 1; i < 2*n; i++) pre[i] = pre[i-1]+lt[(i-1)%n]; return; } int compare_plants(int x, int y) { // if (x != (y+1)%n && y != (x+1)%n) return 0; // if (x == (y+1)%n) return 2*(!lt[y])-1; // return 2*lt[x]-1; // if (x < y) { if (pre[y]-pre[x] == y-x) return -1; if (pre[x+n]-pre[y] == x+n-y) return 1; if (pre[y]-pre[x] == 0) return 1; if (pre[x+n]-pre[y] == 0) return -1; return 0; // } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...