이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<ll>> adj;
ll n, t;
ll get(ll x){
ll y = 0;
while((1LL << y) < x) y++;
return (1LL << y);
}
ll rg(vector<ll> & segtree, ll a, ll b){
a += t, b += t;
ll ans = 0;
while(a <= b){
if(a % 2 == 1) ans += segtree[a++];
if(b % 2 == 0) ans += segtree[b--];
a /= 2, b /= 2;
}
return ans;
}
vector<ll> segtree;
void init(int k, std::vector<int> r){
n = r.size();
t = get(n);
segtree.resize(2*t);
for(int i = 0; i < n; i++) segtree[i+t] = r[i];
for(int i = t-1; i >= 1; i--) segtree[i] = segtree[2*i]+segtree[2*i+1];
return;
}
int compare_plants(int x, int y){
if(rg(segtree, x, y-1) == y-x || rg(segtree, y, n-1) + rg(segtree, 0, x-1) == 0) return 1;
if(rg(segtree, x, y-1) == 0 || rg(segtree, y, n-1) + rg(segtree, 0, x-1) == n-y+x) return -1;
return 0;
return 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... |