답안 #533262

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
533262 2022-03-05T08:10:03 Z christinelynn 사육제 (CEOI14_carnival) C++17
100 / 100
10 ms 292 KB
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

int main(){
    int n; cin >> n;

    vector<int> sim;
    vector<int> belum;
    int warna[155];

    for(int i = 1; i <= n; i++){
        cout << sim.size() + 1;
        for(int j = 0; j < sim.size(); j++){
            cout << " " << sim[j];
        }
        cout << " " << i;
        cout << endl;

        int jawab; cin >> jawab;
        if(jawab == sim.size() + 1){
            sim.pb(i);
        }else{
            belum.pb(i);
        }
    }

    for(int i = 0; i < sim.size(); i++){
        warna[sim[i]] = i + 1;
    }

    for(int i = 0; i < belum.size(); i++){
        int now = belum[i];
        int l = 0, r = sim.size();
        int ans = -1;
        while(l <= r){
            int mid = (l + r)/2;

            cout << mid + 2;
            cout << " " << now;
            for(int j = 0; j <= mid; j++){
                cout << " " << sim[j];
            }
            cout << endl;
            
            int idx = mid + 1;
            int jawab; cin >> jawab;
            if(jawab == idx){
                ans = mid;
                r = mid - 1;
            }else{
                l = mid + 1;
            }
        }
        warna[now] = ans + 1;
    }

    cout << "0";
    for(int i = 1; i <= n; i++){
        cout << " " << warna[i];
    }
    cout << endl;

}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:14:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int j = 0; j < sim.size(); j++){
      |                        ~~^~~~~~~~~~~~
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 |         if(jawab == sim.size() + 1){
      |            ~~~~~~^~~~~~~~~~~~~~~~~
carnival.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0; i < sim.size(); i++){
      |                    ~~^~~~~~~~~~~~
carnival.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 0; i < belum.size(); i++){
      |                    ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 5 ms 200 KB Output is correct
5 Correct 4 ms 200 KB Output is correct
6 Correct 5 ms 292 KB Output is correct
7 Correct 8 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 8 ms 200 KB Output is correct
3 Correct 5 ms 200 KB Output is correct
4 Correct 2 ms 200 KB Output is correct
5 Correct 8 ms 200 KB Output is correct
6 Correct 7 ms 200 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 200 KB Output is correct
2 Correct 6 ms 200 KB Output is correct
3 Correct 7 ms 200 KB Output is correct
4 Correct 3 ms 200 KB Output is correct
5 Correct 8 ms 200 KB Output is correct
6 Correct 8 ms 200 KB Output is correct
7 Correct 6 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 200 KB Output is correct
2 Correct 7 ms 288 KB Output is correct
3 Correct 4 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 10 ms 200 KB Output is correct
6 Correct 6 ms 200 KB Output is correct
7 Correct 9 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 288 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
3 Correct 7 ms 200 KB Output is correct
4 Correct 7 ms 200 KB Output is correct
5 Correct 7 ms 200 KB Output is correct
6 Correct 5 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct