답안 #1117156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117156 2024-11-22T21:17:06 Z StefanSebez 사육제 (CEOI14_carnival) C++14
100 / 100
16 ms 764 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
int Ask(vector<int>a){
	cout<<a.size()<<" ";
	for(auto i:a) cout<<i<<" ";cout<<endl;
	int x;cin>>x;return x;
}
int main(){
    int n;cin>>n;
    vector<int>b;
    for(int i=1;i<=n;i++){
		b.pb(i);int x=Ask(b);
		if(x!=b.size()) b.pop_back();
    }
    int res[n+10]={0};
    for(int i=0;i<b.size();i++) res[b[i]]=i+1;
    for(int i=1;i<=n;i++){
		int lb=lower_bound(b.begin(),b.end(),i)-b.begin();
		if(lb<b.size()&&b[lb]==i) continue;
		int l=0,r=b.size()-1;
		while(l<=r){
			int mid=l+r>>1;
			vector<int>temp;
			for(int j=0;j<=mid;j++) temp.pb(b[j]);
			temp.pb(i);
			int x=Ask(temp);
			if(x==temp.size()){l=mid+1;}
			else{res[i]=res[b[mid]],r=mid-1;}
		}
    }
    cout<<"0 ";
    for(int i=1;i<=n;i++) cout<<res[i]<<" ";cout<<endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int Ask(std::vector<int>)':
carnival.cpp:10:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   10 |  for(auto i:a) cout<<i<<" ";cout<<endl;
      |  ^~~
carnival.cpp:10:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   10 |  for(auto i:a) cout<<i<<" ";cout<<endl;
      |                             ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:18:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(x!=b.size()) b.pop_back();
      |      ~^~~~~~~~~~
carnival.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for(int i=0;i<b.size();i++) res[b[i]]=i+1;
      |                 ~^~~~~~~~~
carnival.cpp:24:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if(lb<b.size()&&b[lb]==i) continue;
      |      ~~^~~~~~~~~
carnival.cpp:27:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |    int mid=l+r>>1;
      |            ~^~
carnival.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(x==temp.size()){l=mid+1;}
      |       ~^~~~~~~~~~~~~
carnival.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for(int i=1;i<=n;i++) cout<<res[i]<<" ";cout<<endl;
      |     ^~~
carnival.cpp:37:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |     for(int i=1;i<=n;i++) cout<<res[i]<<" ";cout<<endl;
      |                                             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 336 KB Output is correct
2 Correct 14 ms 336 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 7 ms 336 KB Output is correct
6 Correct 5 ms 336 KB Output is correct
7 Correct 10 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 13 ms 336 KB Output is correct
3 Correct 5 ms 336 KB Output is correct
4 Correct 5 ms 336 KB Output is correct
5 Correct 9 ms 336 KB Output is correct
6 Correct 12 ms 336 KB Output is correct
7 Correct 11 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 336 KB Output is correct
2 Correct 10 ms 336 KB Output is correct
3 Correct 14 ms 764 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 11 ms 336 KB Output is correct
6 Correct 12 ms 336 KB Output is correct
7 Correct 13 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 336 KB Output is correct
2 Correct 9 ms 336 KB Output is correct
3 Correct 7 ms 336 KB Output is correct
4 Correct 4 ms 336 KB Output is correct
5 Correct 16 ms 336 KB Output is correct
6 Correct 10 ms 336 KB Output is correct
7 Correct 14 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 336 KB Output is correct
2 Correct 11 ms 336 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 11 ms 440 KB Output is correct
5 Correct 11 ms 504 KB Output is correct
6 Correct 7 ms 336 KB Output is correct
7 Correct 5 ms 336 KB Output is correct