Submission #615601

# Submission time Handle Problem Language Result Execution time Memory
615601 2022-07-31T11:01:25 Z misteg168 Comparing Plants (IOI20_plants) C++17
0 / 100
0 ms 212 KB
#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
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -