답안 #149846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149846 2019-09-01T07:16:18 Z 还没编好(#3801, cauchysheep, fjzzq2002, apiad) On the Grid (FXCUP4_grid) C++17
43 / 100
78 ms 6904 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<<t[i]<<",";
//	cout<<":"<<PutDisks(gg)-N<<"\n";
	if(ms.count(gg)) return ms[gg];
	return ms[gg]=PutDisks(gg);
}
std::vector<int> SortDisks(int N_) {
	srand(time(0));
	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]<<" "<<os<<"\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
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 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 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 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 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 8 ms 512 KB Output is correct
10 Correct 13 ms 896 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 13 ms 1024 KB Output is correct
13 Correct 13 ms 1024 KB Output is correct
14 Correct 14 ms 1024 KB Output is correct
15 Correct 14 ms 1152 KB Output is correct
16 Correct 13 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 8 ms 512 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 13 ms 1024 KB Output is correct
6 Halted 0 ms 0 KB -
7 Correct 14 ms 1024 KB Output is correct
8 Incorrect 78 ms 6904 KB Output isn't correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 13 ms 1024 KB Output is correct
12 Correct 5 ms 256 KB Output is correct
13 Correct 14 ms 1152 KB Output is correct
14 Correct 13 ms 1024 KB Output is correct
15 Correct 13 ms 896 KB Output is correct
16 Correct 22 ms 1920 KB Output is correct
17 Correct 13 ms 1024 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct