답안 #750392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750392 2023-05-29T13:05:49 Z vjudge1 사육제 (CEOI14_carnival) C++17
100 / 100
13 ms 324 KB
#include "bits/stdc++.h"
//#include "/Library/Developer/CommandLineTools/usr/include/c++/v1/bits/stdc++.h"
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define foru(j, a, b) for(int j = a; j <= b; ++j)
#define ford(j, a, b) for(int j = a; j >= b; --j)
#define mp make_pair
#define endl '\n'
#define ll long long
const int maxN = 1e5 + 5;
const int mod = 1e9 + 7;
const ll inf = 1e14;
vector<int> costume;
int ans[maxN];

signed main(){
    IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, val;
    cin >> n;
    foru(i, 1, n){  
        cout << costume.size() + 1 << " ";

        for(int j = 0; j < costume.size(); j++) cout << costume[j] << " ";
        cout << i << endl;
        cout << flush;

        cin >> val;
        if(val == costume.size() + 1){
            ans[i] = costume.size() + 1;
            costume.push_back(i);
        } 
        else{
            int l = 0, r = costume.size() - 1;
            if(l == r){
                ans[i] = ans[1];
                continue;
            }

            while(l < r){
                int mid = (l + r) >> 1;

                cout << mid - l + 2 << " ";
                for(int j = l; j <= mid; j++) cout << costume[j] << " ";
                cout << i << endl; 
                cout << flush;

                cin >> val;
                if(val == 1){
                    ans[i] = ans[costume[l]];
                    break;
                }

                if(val == mid - l + 1){
                    r = mid;
                }
                else{
                    cout << r - mid + 1 << " ";
                    for(int j = mid + 1; j <= r; j++) cout << costume[j] << " ";
                    cout << i << endl; 
                    cout << flush;

                    cin >> val;

                    if(val == 1){
                        ans[i] = ans[costume[r]];
                        break;
                    }

                    if(val == r - mid){
                        l = mid + 1;
                    }
                }
    
               
            }
            
        }
        
    }
    cout << 0 << " ";
    foru(j, 1, n) cout << ans[j] << " ";


   
}
    

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for(int j = 0; j < costume.size(); j++) cout << costume[j] << " ";
      |                        ~~^~~~~~~~~~~~~~~~
carnival.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(val == costume.size() + 1){
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 3 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 13 ms 208 KB Output is correct
4 Correct 3 ms 324 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 4 ms 320 KB Output is correct