답안 #1049852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1049852 2024-08-09T05:46:21 Z 김은성(#11046) 카멜레온의 사랑 (JOI20_chameleon) C++17
0 / 100
0 ms 344 KB
#include "chameleon.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
vector<int> vec;
int askrange(vector<int> cur, int i, int j){
	vector<int> temp;
	for(int u: cur)
		temp.push_back(u);
	for(int k=i; k<=j; k++)
		temp.push_back(vec[k]);
	return Query(temp);
}
void Solve(int N) {
	int i;
	for(i=1; i<=2*N; i++)
		vec.push_back(i);
	for(i=1; i<=N; i++){
		int lo = 0, hi = (int)vec.size() - 1, mid;
		while(1){
			mid = (lo+hi) / 2;
			if(askrange({}, lo, mid) < mid-lo+1)
				hi = mid;
			else if(askrange({}, mid+1, hi) < hi-mid)
				lo = mid+1;
			else
				break;
		}
		int crit = lo;
		lo = mid+1;
		while(lo < hi){
			mid = (lo+hi)/2;
			if(askrange({vec[crit]}, lo, mid) == mid-lo+2)
				lo = mid+1;
			else
				hi = mid;
		}
		//printf("crit=%d lo=%d\n", crit, lo);
		Answer(vec[crit], vec[lo]);
		vec.erase(find(vec.begin(), vec.end(), vec[lo]));
		vec.erase(find(vec.begin(), vec.end(), vec[crit]));
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Wrong Answer [6]
4 Halted 0 ms 0 KB -