Submission #1242832

#TimeUsernameProblemLanguageResultExecution timeMemory
1242832Joshua_Andersson식물 비교 (IOI20_plants)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; typedef vector<ll> vi; typedef vector<vi> vvi; typedef pair<ll, ll> p2; #define rep(i, high) for (ll i = 0; i < (high); i++) #define repp(i, lo, high) for (ll i = (lo); i < (high); i++) #define repe(i, container) for (auto& i : container) #define sz(x) ((ll)(x).size()) #define all(x) begin(x), end(x) vi real_heights; void init(int k, std::vector<int> r) { int n = sz(r); real_heights.resize(n); auto norm = [&](int x) { if (x < 0) return x + n; if (x > n) return x - n; return x; }; rep(i, n) { rep(j, n) { if (r[i] != 0) continue; bool good = 1; for (int l = j - k + 1; l < j; l++) { if (r[norm(l)]==0) { good = 0; break; } } if (good) { real_heights[j] = n - i; for (int l = j - k + 1; l < j; l++) { r[norm(l)]--; } break; } } } return; } int compare_plants(int x, int y) { return real_heights[x] > real_heights[y]; } #if _LOCAL static int n, k, q; static std::vector<int> r; static std::vector<int> x; static std::vector<int> y; static std::vector<int> answer; int main() { assert(scanf("%d%d%d", &n, &k, &q) == 3); r.resize(n); answer.resize(q); for (int i = 0; i < n; i++) { int value; assert(scanf("%d", &value) == 1); r[i] = value; } x.resize(q); y.resize(q); for (int i = 0; i < q; i++) { assert(scanf("%d%d", &x[i], &y[i]) == 2); } fclose(stdin); init(k, r); for (int i = 0; i < q; i++) { answer[i] = compare_plants(x[i], y[i]); } for (int i = 0; i < q; i++) { printf("%d\n", answer[i]); } fclose(stdout); return 0; } #endif
#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...