Submission #1291727

#TimeUsernameProblemLanguageResultExecution timeMemory
1291727ChuanChenComparing Plants (IOI20_plants)C++20
5 / 100
44 ms5120 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 2e5+5; int n, sv[MAXN]; void init(int k, vector<int> r) { n = r.size(); for(int i = 0; i < n; i++){ sv[i+1] = sv[i]+r[i]; } } int compare_plants(int x, int y) { bool swapped = false; if(x>y){ swap(x, y); swapped = true; } if(sv[y]-sv[x] == y-x){ //eh tudo 1, x so cresce ate chegar no y if(swapped) return 1; return -1; } if(sv[y]-sv[x] == 0){ //eh tudo 0, x so decresce ate chegar no y if(swapped) return -1; return 1; } if(sv[n]-(sv[y]-sv[x]) == n-(y-x)){ //eh tudo 1, y so cresce ate chegar no x if(swapped) return -1; return 1; } if(sv[n]-(sv[y]-sv[x]) == 0){ if(swapped) return 1; return -1; } 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...