Submission #835237

#TimeUsernameProblemLanguageResultExecution timeMemory
835237NeroZeinComparing Plants (IOI20_plants)C++17
5 / 100
70 ms8676 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> a; vector<int> ps; void init(int k, vector<int> r) { n = r.size(); a = r; assert(k == 2); ps.resize(n); ps[0] = a[0]; for (int i = 1; i < n; ++i) { ps[i] = ps[i - 1] + a[i]; } } int compare_plants(int x, int y) { assert(x != y); int disxy = x < y ? y - x : n - (x - y); int disyx = y < x ? x - y : n - (y - x); int mn = min(x, y); int mx = max(x, y); int frsum = ps[mx - 1] - (mn ? ps[mn - 1] : 0); int bcksum = ps[n - 1] - frsum; //cout << disxy << ' ' << disyx << ' ' << frsum << ' ' << bcksum << endl; if (x < y) { if (frsum == 0) return 1; if (frsum == disxy) return -1; if (bcksum == 0) return -1; if (bcksum == disyx) return 1; return 0; } else { if (frsum == 0) return -1; if (frsum == disxy) return 1; if (bcksum == 0) return 1; if (bcksum == disyx) 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...