제출 #1133279

#제출 시각아이디문제언어결과실행 시간메모리
1133279alterio식물 비교 (IOI20_plants)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> #include "plants.h" using namespace std; const int mxn = 2e5 + 100; int n, k; int prf[mxn]; int get(int l, int r) { return prf[r] - (l ? prf[l - 1] : 0); } void init(int _k, std::vector<int> r) { k = _k; n = r.size(); for (int i = 0; i < n; i++) prf[i] = (i ? prf[i - 1] : 0) + (r[i] == 1 ? -1 : 1); return; } // 1 > : -1 < : 0 ? int compare_plants(int x, int y) { if (x < y) { int sum = get(x, y - 1); if (abs(sum) == y - x) return sum / abs(sum); } else { int sum = get(x, n - 1); if (y) sum += get(0, y - 1); if (abs(sum) == (n - x + y)) return sum / abs(sum); } 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...