답안 #1041783

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041783 2024-08-02T08:18:16 Z MarwenElarbi 식물 비교 (IOI20_plants) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;
#define fi first
const int nax=2e5+5;
set<pair<int,int>> st;
int tab[nax]; 
void init(int k, std::vector<int> r) {
	int n=r.size();
	for (int i = 0; i < n; ++i)
	{
		tab[i]=r[i];
		if(r[i]==0&&r[(i+1)%n]==1){
			st.insert({(i+1)%n,0});
		}else if(r[i]==1&&r[(i+1)%n]==0){
			st.insert({(i+1)%n,1});
		}
	}
	return;
}

int compare_plants(int x, int y) {
	if(st.size()==0){
		return (tab[x]==1 ? 1 : -1);
	}
	pair<int,int> a=*st.upper_bound({x,1});
	pair<int,int> b=(st.upper_bound({y,1}) != st.end() ? *st.upper_bound({y,1}): *st.begin());
	if(a.fi<y&&b.fi<x){
		return 0;
	}else if(a.fi<y) return (tab[y]==1 ? 1 : -1);
	else return (tab[x]==1 ? -1 : 1);
}
# 결과 실행 시간 메모리 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 348 KB Output isn't correct
3 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 344 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 -