답안 #823269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
823269 2023-08-12T10:17:38 Z NothingXD 식물 비교 (IOI20_plants) C++17
0 / 100
4000 ms 24276 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];
	}
	for (int i = 0; i < 2*n; i++){
		debug(i, l[i], r[i]);
	}
}

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));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 38 ms 3048 KB Output is correct
7 Correct 432 ms 5080 KB Output is correct
8 Correct 3952 ms 24148 KB Output is correct
9 Correct 3899 ms 24180 KB Output is correct
10 Correct 3891 ms 24252 KB Output is correct
11 Correct 3847 ms 24176 KB Output is correct
12 Correct 3938 ms 24276 KB Output is correct
13 Execution timed out 4043 ms 23684 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 38 ms 3048 KB Output is correct
7 Correct 432 ms 5080 KB Output is correct
8 Correct 3952 ms 24148 KB Output is correct
9 Correct 3899 ms 24180 KB Output is correct
10 Correct 3891 ms 24252 KB Output is correct
11 Correct 3847 ms 24176 KB Output is correct
12 Correct 3938 ms 24276 KB Output is correct
13 Execution timed out 4043 ms 23684 KB Time limit exceeded
14 Halted 0 ms 0 KB -