Submission #547510

# Submission time Handle Problem Language Result Execution time Memory
547510 2022-04-10T21:31:20 Z seungho9422 Carnival (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;
      |                                       ^
# Verdict Execution time Memory Grader output
1 Correct 6 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 3 ms 312 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 4 ms 280 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 3 ms 312 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 5 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 3 ms 320 KB Output is correct