Submission #527410

# Submission time Handle Problem Language Result Execution time Memory
527410 2022-02-17T11:11:19 Z jamielim On the Grid (FXCUP4_grid) C++17
0 / 100
1 ms 300 KB
#include "grid.h"
#include <bits/stdc++.h>
using namespace std;

#define pb emplace_back

vector<int> SortDisks(int N) {
	vector<int> test;for(int i=0;i<N;i++)test.pb(i);
	vector<int> cfm;for(int i=0;i<N;i++)cfm.pb(-1);
	bool donepos[N];for(int i=0;i<N;i++)donepos[i]=0;
	set<int> s;for(int i=0;i<N;i++)s.insert(i);
	//for(int i:test)printf("%d ",i);
	//printf("\n");
	int prv=PutDisks(test);
	//printf("%d\n",prv);
	while(!s.empty()){
		int first_unknown=-1;
		int tmp=-1;
		for(int i=0;i<N;i++){
			if(!donepos[i]){
				swap(test[i],tmp);
				if(first_unknown==-1)first_unknown=i;
			}
		}
		swap(test[first_unknown],tmp);
		//for(int i:test)printf("%d ",i);
		//printf("\n");
		int cur=PutDisks(test);
		//printf("%d\n",cur);
		if(cur!=prv-1){
			int x=test[first_unknown];
			cfm[x]=cur-(N-1)+(first_unknown);
			donepos[cfm[x]-1]=1;
			test[cfm[x]-1]=x;
			s.erase(x);
			auto it=s.begin();
			for(int i=0;i<N;i++){
				if(!donepos[i]){
					test[i]=(*it);
					++it;
				}
			}
			//for(int i:test)printf("%d ",i);
			//printf("\n");
			prv=PutDisks(test);
			//printf("%d\n",cur);
		}else prv=cur;
		//printf("cfm: ");
		//for(int i:cfm)printf("%d ",i);
		//printf("\n");
	}
	return cfm;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -