Submission #148159

# Submission time Handle Problem Language Result Execution time Memory
148159 2019-08-31T15:40:18 Z mosiashvililuka Carnival (CEOI14_carnival) C++14
100 / 100
28 ms 396 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[159],z,x,dp[159],k[3];
long long taim,bhb;
pair <int, int> p[3];
long long nicerand(){
	long long isesarandomod=4534;
	taim++;
	long long hji=rand()*rand(),hh;
	hji+=isesarandomod%23;
	hji%=7;
	while(hji>0){
		hji--;
		rand();
	}
	hji=0;hh=1;long long ha=0;
	while(ha<8){
		if(rand()%2==1) hji+=hh;
		hh*=2;
		ha++;
	}
	taim=taim%1000000000000000LL;
	if(taim==0) taim=1;
	long long hi=rand()%432+1;
	hji+=taim*hi;
	hji%=bhb;
	hji++;
	return hji;
}
int rec(int q, int w){
	if(q==w) return f[q];
	bhb=4;
	long long jj=nicerand()*nicerand()%2;
	if(jj==0){
		p[1].first=q;p[1].second=(q+w)/2;
		p[2].first=(q+w)/2+1;p[2].second=w;
	}else{
		p[2].first=q;p[2].second=(q+w)/2;
		p[1].first=(q+w)/2+1;p[1].second=w;
	}
	k[1]=p[1].second-p[1].first+1;
	k[2]=p[2].second-p[2].first+1;
	for(int h=1; h<=2; h++){
		cout<<k[h]<<" ";
		for(int sd=p[h].first; sd<=p[h].second; sd++){
			cout<<sd<<" ";
		}
		cout<<endl;
		cin>>z;
		cout<<endl;
		x=z;
		cout<<k[h]+1<<" ";
		cout<<b<<" ";
		for(int sd=p[h].first; sd<=p[h].second; sd++){
			cout<<sd<<" ";
		}
		cout<<endl;
		cin>>z;
		cout<<endl;
		if(z==x){
			return rec(p[h].first,p[h].second);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=a; b>=1; b--){
		cout<<a-b+1<<" ";
		for(c=b; c<=a; c++) cout<<c<<" ";
		cout<<endl;
		cin>>z;
		cout<<endl;
		dp[b]=z;
	}
	f[a]=1;
	e=1;
	for(b=a-1; b>=1; b--){
		if(dp[b]==dp[b+1]){
			f[b]=rec(b+1,a);
		}else{
			e++;
			f[b]=e;
		}
	}
	cout<<"0 ";
	for(b=1; b<=a; b++) cout<<f[b]<<" ";
	return 0;
}

Compilation message

carnival.cpp: In function 'int rec(int, int)':
carnival.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 26 ms 396 KB Output is correct
2 Correct 24 ms 376 KB Output is correct
3 Correct 11 ms 248 KB Output is correct
4 Correct 6 ms 248 KB Output is correct
5 Correct 27 ms 248 KB Output is correct
6 Correct 21 ms 376 KB Output is correct
7 Correct 21 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 296 KB Output is correct
2 Correct 17 ms 248 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 24 ms 376 KB Output is correct
6 Correct 18 ms 248 KB Output is correct
7 Correct 16 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 248 KB Output is correct
2 Correct 17 ms 248 KB Output is correct
3 Correct 23 ms 376 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 23 ms 376 KB Output is correct
6 Correct 13 ms 248 KB Output is correct
7 Correct 22 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 248 KB Output is correct
2 Correct 27 ms 248 KB Output is correct
3 Correct 11 ms 248 KB Output is correct
4 Correct 4 ms 248 KB Output is correct
5 Correct 20 ms 376 KB Output is correct
6 Correct 16 ms 296 KB Output is correct
7 Correct 15 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 248 KB Output is correct
2 Correct 18 ms 296 KB Output is correct
3 Correct 17 ms 248 KB Output is correct
4 Correct 14 ms 248 KB Output is correct
5 Correct 15 ms 248 KB Output is correct
6 Correct 13 ms 376 KB Output is correct
7 Correct 5 ms 296 KB Output is correct