Submission #1051424

# Submission time Handle Problem Language Result Execution time Memory
1051424 2024-08-10T06:32:07 Z pcc Comparing Plants (IOI20_plants) C++17
5 / 100
40 ms 13048 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

const int mxn = 4e5+10;
#define pii pair<int,int>
#define fs first
#define sc second
int arr[mxn];
int N;
int K;
int pos[mxn];
int small[mxn],big[mxn];

void init(int k, std::vector<int> r) {
	K = k;
	N = r.size();
	for(int i = 0;i<N;i++)arr[i] = arr[i+N] = r[i];
	iota(small,small+mxn,0);
	iota(big,big+mxn,0);
	int p1 = N*2,p2 = N*2;
	for(int i = N*2-1;i>=0;i--){
		if(arr[i])p2 = i;
		else p1 = i;
		small[i] = p1;
		big[i] = p2;
	}
	return;
}

int compare_plants(int x, int y) {
	int rev = (x>y?-1:1);
	if(x>y)swap(x,y);
	if(big[x]>=y)return rev*(1);
	else if(small[x]>=y)return rev*(-1);
	if(big[y]>=x+N)return rev*(-1);
	else if(small[y]>=x+N)return rev*(1);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4488 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 26 ms 8400 KB Output is correct
7 Correct 31 ms 9832 KB Output is correct
8 Correct 40 ms 12916 KB Output is correct
9 Correct 39 ms 12884 KB Output is correct
10 Correct 38 ms 12884 KB Output is correct
11 Correct 39 ms 12916 KB Output is correct
12 Correct 39 ms 13048 KB Output is correct
13 Correct 37 ms 12892 KB Output is correct
14 Correct 37 ms 12912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Incorrect 1 ms 4700 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Incorrect 1 ms 4700 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Incorrect 1 ms 4700 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4696 KB Output is correct
4 Incorrect 1 ms 4700 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Incorrect 1 ms 4700 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4700 KB Output is correct
2 Correct 1 ms 4488 KB Output is correct
3 Correct 1 ms 4700 KB Output is correct
4 Correct 1 ms 4700 KB Output is correct
5 Correct 1 ms 4700 KB Output is correct
6 Correct 26 ms 8400 KB Output is correct
7 Correct 31 ms 9832 KB Output is correct
8 Correct 40 ms 12916 KB Output is correct
9 Correct 39 ms 12884 KB Output is correct
10 Correct 38 ms 12884 KB Output is correct
11 Correct 39 ms 12916 KB Output is correct
12 Correct 39 ms 13048 KB Output is correct
13 Correct 37 ms 12892 KB Output is correct
14 Correct 37 ms 12912 KB Output is correct
15 Correct 1 ms 4700 KB Output is correct
16 Correct 1 ms 4700 KB Output is correct
17 Incorrect 1 ms 4700 KB Output isn't correct
18 Halted 0 ms 0 KB -