Submission #66115

# Submission time Handle Problem Language Result Execution time Memory
66115 2018-08-09T15:28:20 Z naderjemel Carnival (CEOI14_carnival) C++14
100 / 100
11 ms 572 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;
    				}
    			}
    		}
    	}	
    	for(int i=0;i<=n;i++) printf("%d ", rs[i]); printf("\n");
    	return 0;
    }

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:47:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
      for(int i=0;i<=n;i++) printf("%d ", rs[i]); printf("\n");
      ^~~
carnival.cpp:47:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
      for(int i=0;i<=n;i++) printf("%d ", rs[i]); printf("\n");
                                                  ^~~~~~
carnival.cpp:5:18: 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:19: 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:14: 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 7 ms 248 KB Output is correct
2 Correct 7 ms 308 KB Output is correct
3 Correct 4 ms 412 KB Output is correct
4 Correct 4 ms 420 KB Output is correct
5 Correct 7 ms 436 KB Output is correct
6 Correct 5 ms 496 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 6 ms 564 KB Output is correct
5 Correct 5 ms 564 KB Output is correct
6 Correct 4 ms 564 KB Output is correct
7 Correct 6 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 564 KB Output is correct
2 Correct 6 ms 564 KB Output is correct
3 Correct 8 ms 564 KB Output is correct
4 Correct 5 ms 572 KB Output is correct
5 Correct 7 ms 572 KB Output is correct
6 Correct 7 ms 572 KB Output is correct
7 Correct 11 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 572 KB Output is correct
2 Correct 7 ms 572 KB Output is correct
3 Correct 6 ms 572 KB Output is correct
4 Correct 6 ms 572 KB Output is correct
5 Correct 10 ms 572 KB Output is correct
6 Correct 5 ms 572 KB Output is correct
7 Correct 9 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 572 KB Output is correct
2 Correct 8 ms 572 KB Output is correct
3 Correct 7 ms 572 KB Output is correct
4 Correct 9 ms 572 KB Output is correct
5 Correct 8 ms 572 KB Output is correct
6 Correct 6 ms 572 KB Output is correct
7 Correct 5 ms 572 KB Output is correct