답안 #738131

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
738131 2023-05-08T07:56:50 Z bobthebuilder 식물 비교 (IOI20_plants) C++17
5 / 100
103 ms 46204 KB
#include "plants.h"
#include<bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define lowb(x) (x&(-x))
#define ALL(_x) _x.begin(),_x.end()
#define pii pair<int,int>
#define f first
#define s second
#define SORT_UNIQUE(x) sort(ALL(x)),x.erase(unique(ALL(x)),x.end())
#define ll long long
#define MNTO(x,y) x=min(x,y)
#define MXTO(x,y) x=max(x,y)
const int maxn=4e5+5;
vector<int> v[maxn];
int in[maxn];
int l[maxn],r[maxn];
void dfs(int u){
	l[u]=r[u]=u;
	for(int x:v[u]){
		dfs(x);
		MNTO(l[u],l[x]),MXTO(r[u],r[x]);
	}
}
int n;
void init(int k, std::vector<int> r) {
	n=sz(r);
	REP(i,2*n-1){
		if(r[i%n]==1){
			v[i+1].pb(i),in[i]++;
		}
		else v[i].pb(i+1),in[i+1]++;
	}
	REP(i,2*n){
		if(!in[i]){
			dfs(i);
		}	
	}
}

int compare_plants(int x, int y) {
	if((l[x]<=y and y<=r[x]) or (r[x]-n>=y) or (l[x+n]<=y)){
		return 1;
	}
	swap(x,y);
	if((l[x]<=y and y<=r[x]) or (r[x]-n>=y) or (l[x+n]<=y)){
		return -1;
	}
	return 0;
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 51 ms 12428 KB Output is correct
7 Correct 60 ms 14416 KB Output is correct
8 Correct 103 ms 30124 KB Output is correct
9 Correct 100 ms 33648 KB Output is correct
10 Correct 96 ms 34028 KB Output is correct
11 Correct 98 ms 35856 KB Output is correct
12 Correct 100 ms 40212 KB Output is correct
13 Correct 100 ms 46204 KB Output is correct
14 Correct 100 ms 46200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Incorrect 5 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Incorrect 5 ms 9684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Incorrect 5 ms 9684 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Incorrect 5 ms 9684 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Incorrect 5 ms 9684 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Correct 6 ms 9684 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 51 ms 12428 KB Output is correct
7 Correct 60 ms 14416 KB Output is correct
8 Correct 103 ms 30124 KB Output is correct
9 Correct 100 ms 33648 KB Output is correct
10 Correct 96 ms 34028 KB Output is correct
11 Correct 98 ms 35856 KB Output is correct
12 Correct 100 ms 40212 KB Output is correct
13 Correct 100 ms 46204 KB Output is correct
14 Correct 100 ms 46200 KB Output is correct
15 Correct 5 ms 9684 KB Output is correct
16 Correct 5 ms 9684 KB Output is correct
17 Incorrect 5 ms 9684 KB Output isn't correct
18 Halted 0 ms 0 KB -