QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294251#4830. Transfer of Dutyucup-team987#0 57ms160040kbC++201.2kb2023-12-30 10:49:312023-12-30 10:49:32

Judging History

你现在查看的是最新测评结果

  • [2023-12-30 10:49:32]
  • 评测
  • 测评结果:0
  • 用时:57ms
  • 内存:160040kb
  • [2023-12-30 10:49:31]
  • 提交

answer

#include<iostream>
#include<cassert>
#include<random>
using namespace std;
const int W=20,N=20;
const int M=1e6;
using ull=unsigned long long;
ull B[M][N];
mt19937_64 rng(114514);
ull Hash[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	{
		for(int i=0;i<M;i++)
		{
			B[i][0]=i+1;
			for(int j=1;j<N;j++)B[i][j]=rng();
		}
	}
	string op;cin>>op;
	if(op=="start")
	{
		for(int i=0;i<N;i++)Hash[i]=0;
	}
	else
	{
		cin.ignore();
		string T;
		getline(cin,T);
		for(int i=0;i<N;i++)
		{
			string s=T.substr(i*W,W);
			Hash[i]=0;
			for(char c:s)Hash[i]=Hash[i]*10+(ull)(c-'0');
		}
	}
	int n;cin>>n;
	for(;n--;)
	{
		int id;cin>>id;
		id--;
		bool zero=true;
		for(int i=0;i<N;i++)
		{
			Hash[i]^=B[id][i];
			if(Hash[i]!=0)zero=false;
		}
		if(zero)cout<<"0\n";
		else
		{
			ull t=Hash[0];
			if(t<=M)
			{
				bool ok=true;
				for(int i=0;i<N;i++)if(Hash[i]!=B[t-1][i])ok=false;
				if(ok)cout<<t<<"\n";
				else cout<<"-1\n";
			}
		}
	}
	if(op=="start")
	{
		string ret(N*W,'0');
		for(int i=0;i<N;i++)
		{
			string s=to_string(Hash[i]);
			assert(s.size()<=W);
			int off=i*W+W-s.size();
			for(int j=0;j<s.size();j++)ret[off+j]=s[j];
		}
		cout<<ret<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 46ms
memory: 160004kb

input:

start
5
10
14
10
12
10

output:

10
-1
14
-1
-1
000000000000000000080330425296877428667110035214298550866991067255112796348237390805511390088131849907746254900427672681087772400073055477511782129083005299998805899223080855259587063015363184701761901350708370337611397407572453905257467498018107827078151219010612283369321469018314613...

input:

resume
00000000000000000008033042529687742866711003521429855086699106725511279634823739080551139008813184990774625490042767268108777240007305547751178212908300529999880589922308085525958706301536318470176190135070837033761139740757245390525746749801810782707815121901061228336932146901831461384133685...

output:

-1
-1
-1
277
0
12

result:

ok 

Test #2:

score: 100
Accepted
time: 57ms
memory: 159856kb

input:

start
1
1

output:

1
0000000000000000000100441197956009941593043057659034650458460888991557156316174704859282362602690976135974979152599307861765072272865394119903808093582736786988026761520659275238221655884536377030698014818386845400709988090641840115754394040257587200324936082313227449533655022682139113517581492973...

input:

resume
00000000000000000001004411979560099415930430576590346504584608889915571563161747048592823626026909761359749791525993078617650722728653941199038080935827367869880267615206592752382216558845363770306980148183868454007099880906418401157543940402575872003249360823132274495336550226821391135175814...

output:

0

result:

ok 

Test #3:

score: 0
Wrong Answer
time: 43ms
memory: 160040kb

input:

start
1
1000000

output:

1000000
0000000000000100000006850439375040105735100573467881115074600444867077001615904900135457921239553872139713381495529790480737931750893300285512432070119880360451004785126217842954021666667416697915106505637416160145393959108604397273855011980034719578140335765609176922362177338598109811297075...

input:

resume
00000000000001000000068504393750401057351005734678811150746004448670770016159049001354579212395538721397133814955297904807379317508933002855124320701198803604510047851262178429540216666674166979151065056374161601453939591086043972738550119800347195781403357656091769223621773385981098112970753...

output:

1

result:

wrong answer