Submission #66114

# Submission time Handle Problem Language Result Execution time Memory
66114 2018-08-09T15:24:15 Z naderjemel Carnival (CEOI14_carnival) C++14
100 / 100
14 ms 668 KB
#include <bits/stdc++.h>
using namespace std;
int rs[160];
int main(){
	int n; scanf("%d",&n);
	vector<int> bs;
	map<int,int> mp;
	mp[1]=1;
	rs[1]=1;
	int book=2;
	bs.push_back(1);
	for(int i=2;i<=n;i++){
		printf("%d ", (int)bs.size()+1);
		for(int j:bs) printf("%d ", j);
		printf("%d\n", i);
		fflush(stdout);
		int r; scanf("%d",&r);
		if(r==(int)bs.size()+1){
			bs.push_back(i);
			mp[i]=book;
			rs[i]=book;
			book++;
		}
		else{
			int lo=0,hi=(int)bs.size()-1;
			while(lo<=hi){
				int mid=(lo+hi)/2;
				int sz=mid-lo+2;
				printf("%d ", sz);
				for(int j=lo;j<=mid;j++) printf("%d ", bs[j]);
				printf("%d\n",i);
				fflush(stdout);
				scanf("%d",&r);
				if(r==1){
					rs[i]=mp[bs[lo]];
					break;
				}
				else if(r==sz){
					lo=mid+1;
				}
				else{
					hi=mid;
				}
			}
		}
	}	
	printf("0\n");
	for(int i=1;i<=n;i++) printf("%d ", rs[i]); printf("\n");
	return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:48:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=1;i<=n;i++) printf("%d ", rs[i]); printf("\n");
  ^~~
carnival.cpp:48:46: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=1;i<=n;i++) printf("%d ", rs[i]); printf("\n");
                                              ^~~~~~
carnival.cpp:5:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d",&n);
         ~~~~~^~~~~~~~~
carnival.cpp:17:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int r; scanf("%d",&r);
          ~~~~~^~~~~~~~~
carnival.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&r);
     ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 5 ms 428 KB Output is correct
4 Correct 5 ms 612 KB Output is correct
5 Correct 6 ms 612 KB Output is correct
6 Correct 4 ms 612 KB Output is correct
7 Correct 10 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 612 KB Output is correct
2 Correct 11 ms 612 KB Output is correct
3 Correct 5 ms 612 KB Output is correct
4 Correct 6 ms 612 KB Output is correct
5 Correct 7 ms 612 KB Output is correct
6 Correct 9 ms 612 KB Output is correct
7 Correct 11 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 612 KB Output is correct
2 Correct 8 ms 612 KB Output is correct
3 Correct 11 ms 612 KB Output is correct
4 Correct 6 ms 612 KB Output is correct
5 Correct 8 ms 612 KB Output is correct
6 Correct 14 ms 668 KB Output is correct
7 Correct 10 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 668 KB Output is correct
2 Correct 8 ms 668 KB Output is correct
3 Correct 9 ms 668 KB Output is correct
4 Correct 8 ms 668 KB Output is correct
5 Correct 8 ms 668 KB Output is correct
6 Correct 6 ms 668 KB Output is correct
7 Correct 12 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 668 KB Output is correct
2 Correct 11 ms 668 KB Output is correct
3 Correct 8 ms 668 KB Output is correct
4 Correct 10 ms 668 KB Output is correct
5 Correct 4 ms 668 KB Output is correct
6 Correct 8 ms 668 KB Output is correct
7 Correct 7 ms 668 KB Output is correct