답안 #545251

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
545251 2022-04-04T05:34:15 Z Jomnoi 사육제 (CEOI14_carnival) C++17
100 / 100
9 ms 320 KB
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;

const int N = 160;

int n, l, r, pos, mid, res, prv, now;
int ans[N];
vector <int> vec;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cout << i << ' ';
        for(int j = 1; j <= i; j++) {
            cout << j << ' ';
        }
        cout << endl;

        cin >> now;
        if(now != prv) {
            vec.push_back(i);
            ans[i] = now;
            prv = now;
            continue;
        }

        l = 0, r = vec.size() - 1, pos;
        while(l <= r) {
            mid = (l + r) / 2;

            cout << mid + 2 << ' ';
            for(int i = 0; i <= mid; i++) {
                cout << vec[i] << ' ';
            }
            cout << i << endl;

            cin >> res;
            if(res < mid + 2) {
                r = mid - 1;
                pos = mid;
            }
            else {
                l = mid + 1;
            }
        }
        ans[i] = ans[vec[pos]];
    }

    for(int i = 0; i <= n; i++) {
        cout << ans[i] << ' ';
    }
    cout << endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:29:39: warning: right operand of comma operator has no effect [-Wunused-value]
   29 |         l = 0, r = vec.size() - 1, pos;
      |                                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 2 ms 316 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 3 ms 208 KB Output is correct
7 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 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 6 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 2 ms 320 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 208 KB Output is correct
2 Correct 7 ms 228 KB Output is correct
3 Correct 3 ms 208 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 3 ms 316 KB Output is correct