답안 #597974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597974 2022-07-17T08:47:32 Z jamezzz On the Grid (FXCUP4_grid) C++17
0 / 100
1 ms 212 KB
#include "grid.h"
#include <bits/stdc++.h>
using namespace std;

bool use[1005];
deque<int> dq;
set<pair<int,int>> done;

int ask(){
	vector<int> v;
	for(int i:dq)v.push_back(i);
	for(auto it:done)v.push_back(it.second);
	//printf("ask: ");
	//for(int i:v)printf("%d ",i);
	//printf("\n");
	return PutDisks(v);
}

vector<int> SortDisks(int N){
	for(int i=0;i<N;++i)dq.push_back(i);
	vector<int> ans(N);
	int pv=ask();
	while(!dq.empty()){
		if(dq.size()==1){
			for(int i=1;i<=N;++i){
				if(!use[i])ans[dq[0]]=i;
			}
			break;
		}
		while(true){
			int x=dq.back();
			dq.pop_back();
			dq.push_front(x);
			int cur=ask();
			if(cur<pv&&dq.size()==2){
				swap(cur,pv);
				swap(dq[0],dq[1]);
			}
			if(cur>=pv){
				int res=cur-N+1;
				use[res]=true;
				ans[dq.front()]=res;
				done.insert({res,dq.front()});
				dq.pop_front();
				break;
			}
			pv=cur;
		}
	}
	//printf("ans: ");
	//for(int i:ans)printf("%d ",i);
	//printf("\n");
	return ans;
}
# 결과 실행 시간 메모리 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 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 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -