답안 #1014705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014705 2024-07-05T10:10:04 Z Unforgettablepl 식물 비교 (IOI20_plants) C++17
0 / 100
0 ms 600 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> limit;
vector<int> p;

void init(int k, std::vector<int> r) {
	int n = r.size();
	p.resize(n);
	for(int i=0;i<n;i++)p[i]=min(max(0,r[i]-r[(i+1)%n]),1);
	r=p;
	limit.resize(n);
	vector<bool> visited(n);
	function<int(int,int)> dfs = [&](int x,int type){
		if(r[x]!=type)return x;
		if(visited[x])return limit[x];
		visited[x] = true;
		return limit[x] = dfs((x+1)%n,type);
	};
	for(int i=0;i<n;i++)dfs(i,r[i]);
}

int compare_plants(int x, int y) {
	if(x>y)return -compare_plants(y,x);
	if(limit[x]<x or y<=limit[x]){
		if(p[x])return -1;
		else return 1;
	}
	if(x<=limit[y] and limit[y]<y){
		if(p[y])return 1;
		else return -1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -