Submission #622344

#TimeUsernameProblemLanguageResultExecution timeMemory
622344happypotatoComparing Plants (IOI20_plants)C++17
0 / 100
0 ms212 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(r, n - 1) + st1psquery(0, l); return (st1ps[r] - (l == 0 ? 0 : st1ps[l - 1])); } int st1query(int l, int r) { int diff = r - l; int ret1 = st1psquery(r - 1, l), ret2 = st1psquery(r, l - 1); if (ret1 == diff || ret2 == 0) return 1; else if (ret1 == 0 || ret2 == n - diff) return -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:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
#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...