이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "plants.h"
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rank fuck
using namespace std;
using lint = long long;
using llf = long double;
using pi = pair<lint, lint>;
const int MAXN = 200005;
int n, rank[MAXN];
lint L[MAXN], R[MAXN], DL[MAXN], DR[MAXN];
vector<int> lev[MAXN];
void init(int k, std::vector<int> r) {
n = sz(r);
int layer = 0;
int solved = 0;
while(count(rank, rank + n, 0)){
vector<int> vect;
for(int j=0; j<n; j++){
if(r[j]) continue;
bool claim = true;
for(int x=1; x<=k-1; x++){
if(r[(j-x+n)%n] == 0) claim = false;
}
if(claim) vect.push_back(j);
}
layer++;
for(auto &j : vect) if(!rank[j]) rank[j] = layer;
for(auto &j : vect){
r[j] = k - 1;
for(int x=1; x<=k-1; x++){
r[(j-x+n)%n]--;
}
}
}
for(int i=0; i<n; i++){
lev[rank[i]].push_back(i);
}
set<int> s;
for(int i=layer; i; i--){
for(auto &j : lev[i]){
auto qq = s.upper_bound(j - k);
auto rr = s.lower_bound(j + k);
int L = -1, R = -1;
if(qq != s.end() && *qq < j) L = (*qq + n) % n;
if(rr != s.begin() && *prev(rr) > j) R = *prev(rr) % n;
if(~L) DL[j] = DL[L] + (j - L + n) % n;
if(~R) DR[j] = DR[R] + (R - j + n) % n;
}
for(auto &j : lev[i]){
s.insert(j-n);
s.insert(j);
s.insert(j+n);
}
}
}
int compare_plants(int x, int y) {
if(rank[x] == rank[y]) return 0;
if(rank[x] > rank[y]) return -compare_plants(y, x);
lint st = x - DL[x];
lint ed = x + DR[x];
return st <= y && y <= ed ? 1 : 0;
}
컴파일 시 표준 에러 (stderr) 메시지
plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:19:6: warning: unused variable 'solved' [-Wunused-variable]
19 | int solved = 0;
| ^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |