Submission #622353

#TimeUsernameProblemLanguageResultExecution timeMemory
622353happypotatoComparing Plants (IOI20_plants)C++17
5 / 100
89 ms8672 KiB
#include "plants.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define ff first #define ss second #define pb push_back vector<int> r; int n, k; int st; void st1init(); void init(int K, vector<int> R) { n = R.size(); k = K; r = R; if (k == 2) { st = 1; st1init(); } return; } vector<int> st1ps; void st1init() { st1ps.resize(n); st1ps[0] = r[0]; for (int i = 1; i < n; i++) { st1ps[i] = st1ps[i - 1] + r[i]; } } int st1psquery(int l, int r) { if (l > r) return st1psquery(l, n - 1) + st1psquery(0, r); return (st1ps[r] - (l == 0 ? 0 : st1ps[l - 1])); } int st1query(int l, int r) { bool large = (l > r); if (large) swap(l, r); int ret1 = st1psquery(l, r - 1), ret2 = st1psquery(r, (l == 0 ? n - 1 : l - 1)); if (ret1 == r - l || ret2 == 0) return (large ? 1 : -1); else if (ret1 == 0 || ret2 == n - r + l) return (large ? -1 : 1); else return 0; } int compare_plants(int x, int y) { if (st == 1) return st1query(x, y); }

Compilation message (stderr)

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#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...