Submission #1213021

#TimeUsernameProblemLanguageResultExecution timeMemory
1213021thelegendary08Comparing Plants (IOI20_plants)C++17
5 / 100
50 ms5704 KiB
#include "plants.h" #include<bits/stdc++.h> #define pb push_back #define mp make_pair #define f0r(i,n) for(int i = 0; i<n; i++) #define FOR(i, k, n) for(int i = k; i<n; i++) #define vi vector<int> #define vvi vector<vi> #define pii pair<int,int> #define vb vector<bool> #define vout(v) for(auto u : v)cout<<u<<' '; cout<<'\n'; #define dout(x) cout<<x<<' '<<#x<<'\n'; #define dout2(x,y) cout<<x<<' '<<#x<<' '<<y<<' '<<#y<<'\n'; using namespace std; int n; vi v; int k; vi ps; int sum(int l, int r){ // dout2(l,r); int thing, len; if(l <= r){ thing = ps[r+1] - ps[l]; len = r - l + 1; } else{ //sum from r + 1 to l - 1 thing = ps[n] - (ps[l] - ps[r+1]); len = n - (l - r - 1); } // dout2(thing,len); if(thing == len)return 1; if(thing == 0)return 0; return -1; } void init(int k, std::vector<int> r) { v = r; n = r.size(); ::k=k; ps.resize(n+1); FOR(i, 1, n+1){ ps[i] = ps[i-1] + r[i-1]; } } int compare_plants(int x, int y) { //path from x to y is all 1, means y is taller, return -1 int rhs = (x == 0) ? n-1 : x-1; if(sum(x, y-1) == 1){ return -1; } else if(sum(x, y-1) == 0){ return 1; } else if(sum(y, rhs) == 1){ return 1; } else if(sum(y, rhs) == 0){ return -1; } else 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...