Submission #572793

#TimeUsernameProblemLanguageResultExecution timeMemory
572793kartelComparing Plants (IOI20_plants)C++14
5 / 100
106 ms16500 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "plants.h" #define pb push_back #define sz(x) (int)x.size() using namespace std; const int N = 1e6 + 500; int le[N], ri[N], n; void init(int k, vector <int> r) { n = sz(r); vector <vector <int> > g(n); for (int i = 0; i < n * 3; i++) { if (!r[i % n]) { le[i] = (i - 1 >= 0 ? le[i - 1] : -1); } else { le[i] = i; } } for (int i = n * 3 - 1; i >= 0; i--) { if (r[i % n]) { ri[i] = ri[i + 1]; } else { ri[i] = i; } } } int compare_plants(int x, int y) { if (le[x + n - 1] + 1 <= y && y <= ri[x + n]) { return -1; } if (le[x + n - 1] + 1 <= y + n && y + n <= ri[x + n]) { return -1; } if (le[x + n - 1] + 1 <= y + 2 * n && y + 2 * n <= ri[x + n]) { return -1; } if (le[y + n - 1] + 1 <= x && x <= ri[y + n]) { return 1; } if (le[y + n - 1] + 1 <= x + n && x + n <= ri[y + n]) { return 1; } if (le[y + n - 1] + 1 <= x + 2 * n && x + 2 * n <= ri[y + n]) { 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...