Submission #616929

#TimeUsernameProblemLanguageResultExecution timeMemory
616929wiwihoComparing Plants (IOI20_plants)C++14
5 / 100
122 ms10320 KiB
#include "plants.h" #include <bits/stdc++.h> #define iter(a) a.begin(), a.end() #define lsort(a) sort(iter(a)) #define gsort(a) sort(iter(a), greater<>()) #define eb emplace_back #define ef emplace_front #define pob pop_back() #define pof pop_front() #define mp make_pair #define F first #define S second #define uni(a) a.resize(unique(iter(a)) - a.begin()) #define printv(a, b) { \ for(auto pv : a) b << pv << " "; \ b << "\n"; \ } using namespace std; typedef long long ll; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename A, typename B> ostream& operator<<(ostream& o, pair<A, B> p){ return o << '(' << p.F << ',' << p.S << ')'; } int n; vector<int> r; vector<int> rg, rs; void init(int k, vector<int> _r){ r = _r; n = r.size(); assert(k == 2); for(int i = 0; i < n; i++) r.eb(r[i]); rg.resize(n); rs.resize(n); for(int i = 2 * n - 2; i >= 0; i--){ if(r[i] == 0) rg[i % n] = rg[(i + 1) % n] + 1; else rs[i % n] = rs[(i + 1) % n] + 1; } } int compare_plants(int x, int y){ // x < y // x --> y if(x + rg[x] >= y) return 1; if(x + rs[x] >= y) return -1; // y --> x if(y + rg[y] >= x + n) return -1; if(y + rs[y] >= x + n) 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...