Submission #1041783

#TimeUsernameProblemLanguageResultExecution timeMemory
1041783MarwenElarbiComparing Plants (IOI20_plants)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #include "plants.h" using namespace std; #define fi first const int nax=2e5+5; set<pair<int,int>> st; int tab[nax]; void init(int k, std::vector<int> r) { int n=r.size(); for (int i = 0; i < n; ++i) { tab[i]=r[i]; if(r[i]==0&&r[(i+1)%n]==1){ st.insert({(i+1)%n,0}); }else if(r[i]==1&&r[(i+1)%n]==0){ st.insert({(i+1)%n,1}); } } return; } int compare_plants(int x, int y) { if(st.size()==0){ return (tab[x]==1 ? 1 : -1); } pair<int,int> a=*st.upper_bound({x,1}); pair<int,int> b=(st.upper_bound({y,1}) != st.end() ? *st.upper_bound({y,1}): *st.begin()); if(a.fi<y&&b.fi<x){ return 0; }else if(a.fi<y) return (tab[y]==1 ? 1 : -1); else return (tab[x]==1 ? -1 : 1); }
#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...