Submission #553624

#TimeUsernameProblemLanguageResultExecution timeMemory
553624InternetPerson10Comparing Plants (IOI20_plants)C++17
0 / 100
1 ms296 KiB
#include "plants.h" #include <bits/stdc++.h> typedef long long ll; using namespace std; ll BIG = 1e7; vector<ll> ans; int k, n; void init(int g, std::vector<int> r) { k = g; k--; n = r.size(); ans.resize(n); if(k == 1) { ans.resize(3*n+1); ans[0] = 0; for(int i = 0; i < 3*n+1; i++) { if(r[i%n]) ans[i] = ans[i-1] - 1; else ans[i] = ans[i-1] + 1; } } return; } int compare_plants(int x, int y) { if(k == 1) { for(int i = x + n; i <= 3*n; i += n) { for(int j = y + n; j <= 3*n; j += n) { int a = min(i, j); int b = max(i, j); if(ans[b] - ans[a] == b - a) { if(a == i) return -1; return 1; } if(ans[a] - ans[b] == b - a) { if(a == i) return 1; return -1; } } } return 0; } }

Compilation message (stderr)

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