Submission #149796

# Submission time Handle Problem Language Result Execution time Memory
149796 2019-09-01T07:10:48 Z 还没编好(#3801, cauchysheep, fjzzq2002, apiad) On the Grid (FXCUP4_grid) C++17
0 / 100
6 ms 512 KB
#include "grid.h"
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int t[SZ],N;
bool s[SZ],mk[SZ];
map<vector<int>,int> ms;
int qry()
{
	vector<int> gg(N);
	for(int i=0;i<N;++i) gg[t[i]]=i;
//	for(int i=0;i<N;++i)
//		cout<<gg[i]<<",";
//	cout<<":"<<PutDisks(gg)-N<<"\n";
	if(ms.count(gg)) return ms[gg];
	return ms[gg]=PutDisks(gg);
}
std::vector<int> SortDisks(int N_) {
	N=N_;
	for(int i=0;i<N;++i)
		t[i]=i;
	random_shuffle(t,t+N);
	while(1)
	{
		int g=qry()-N;
		if(!g) break;
		//0..g-1 -> 1..g-1,1
		//skip sures
		vector<pii> o;
		for(int j=0;j<N;++j)
			if(t[j]<N-g&&!s[j]) o.pb(pii(t[j],j));
		if(!o.size()) break;
		int os=o.size();
		sort(o.begin(),o.end());
		for(int j=0;j+1<os;++j)
			t[o[j].se]=o[j+1].fi;
		t[o[os-1].se]=o[0].fi;
		int w=qry()-N;
		if(w==g-1) continue;
		t[o[os-1].se]=t[o[os-1].se]+w;
	//	cout<<"RO"<<o[os-1].se<<":"<<t[o[os-1].se]<<"\n";
		s[o[os-1].se]=1;
		o.clear();
		for(int j=0;j<N;++j)
			if(!s[j]) o.pb(pii(t[j],j));
		sort(o.begin(),o.end());
		for(int j=0;j<N;++j) mk[j]=0;
		for(int j=0;j<N;++j)
			if(s[j]) mk[t[j]]=1;
		for(int j=N-1;j>=0;--j)
			if(!mk[j])
			{
				assert(!o.empty());
//				cout<<j<<"!\n";
				t[o.back().se]=j,o.pop_back();
			}
	}
	vector<int> r(N);
	for(int j=0;j<N;++j) r[j]=t[j]+1;
	return r;
}
#ifdef LOCAL
#define N NN
#include "grader.cpp"
#endif
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Halted 0 ms 0 KB -
6 Correct 6 ms 384 KB Output is correct