Submission #1041770

#TimeUsernameProblemLanguageResultExecution timeMemory
1041770MarwenElarbiComparing Plants (IOI20_plants)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "plants.h" using namespace std; const int nax=2e5+5; int mx[nax]; int mn[nax]; void init(int k, std::vector<int> r) { int n=r.size(); for (int i = 0; i < n; ++i) { mx[i]=i; mn[i]=i; } for (int i = 0; i < n; ++i) { if(r[i]==0){ mn[(i+1)%n]=mn[i]; }else{ mx[(i+1)%n]=mx[i]; } } for (int i = 1; i < n; ++i) { if(r[i-1]==0){ mn[i]=mn[i-1]; }else{ mx[i]=mx[i-1]; } } return; } int compare_plants(int x, int y) { if(mx[y]<=x){ return -1; }else if(mn[y]<=x){ return 1; }else if(mx[x]>x&&mx[x]<=y){ return 1; }else if(mn[x]>x&&mn[x]<=y){ return -1; }else 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...