답안 #971232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971232 2024-04-28T08:12:56 Z makanhulia 사육제 (CEOI14_carnival) C++17
0 / 100
1 ms 692 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 + 1;
            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 Runtime error 1 ms 432 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 692 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -