Submission #823271

# Submission time Handle Problem Language Result Execution time Memory
823271 2023-08-12T10:18:16 Z NothingXD Comparing Plants (IOI20_plants) C++17
5 / 100
60 ms 8908 KB
#include "plants.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void debug_out(){cerr<<endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cerr << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 4e5 + 10;

int n, k, a[maxn], l[maxn], r[maxn];

void init(int _k, std::vector<int> R) {
	n = R.size();
	k = _k;
	for (int i = 0; i < n; i++){
		a[i] = R[i];
		a[n+i] = a[i];
	}
	l[0] = 0;
	for (int i = 1; i < 2*n; i++){
		if (a[i-1] == 0) l[i] = i;
		else l[i] = l[i-1];
	}
	r[2*n-1] = 2*n-1;
	for (int i = 2*n-2; ~i; i--){
		if (a[i] == 1) r[i] = i;
		else r[i] = r[i+1];
	}

}

int compare_plants(int x, int y) {
	bool flg1;
	if (x < y){
		flg1 = (r[x] >= y || l[x+n] <= y);
	}
	else{
		flg1 = (l[x] <= y || r[x] >= y+n);
	}
	bool flg2;
	if (x > y){
		flg2 = (r[y] >= x || l[y+n] <= x);
	}
	else{
		flg2 = (l[y] <= x || r[y] >= x+n);
	}
	return (flg1? 1: (flg2? -1: 0));
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 40 ms 3120 KB Output is correct
7 Correct 44 ms 3648 KB Output is correct
8 Correct 60 ms 8824 KB Output is correct
9 Correct 60 ms 8824 KB Output is correct
10 Correct 59 ms 8788 KB Output is correct
11 Correct 59 ms 8908 KB Output is correct
12 Correct 60 ms 8824 KB Output is correct
13 Correct 57 ms 8792 KB Output is correct
14 Correct 57 ms 8824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 40 ms 3120 KB Output is correct
7 Correct 44 ms 3648 KB Output is correct
8 Correct 60 ms 8824 KB Output is correct
9 Correct 60 ms 8824 KB Output is correct
10 Correct 59 ms 8788 KB Output is correct
11 Correct 59 ms 8908 KB Output is correct
12 Correct 60 ms 8824 KB Output is correct
13 Correct 57 ms 8792 KB Output is correct
14 Correct 57 ms 8824 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -