Submission #83198

# Submission time Handle Problem Language Result Execution time Memory
83198 2018-11-06T00:47:37 Z RezwanArefin01 Carnival (CEOI14_carnival) C++17
100 / 100
10 ms 644 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; 
typedef pair<int, int> ii;

int n, a[200];

int ask(vector<int> v) {
    cout << v.size(); 
    for(int x : v) cout << " " << x; cout << endl;
    int x; cin >> x; return x; 
}

int main() {
    cin >> n; 
    vector<int> u = {1}; 
    for(int i = 2; i <= n; i++) {
        vector<int> v = u; 
        v.push_back(i); 
        if(ask(v) == v.size()) 
            u = v; 
    }
    for(int i = 0; i < u.size(); i++) 
        a[u[i]] = i + 1; 
    for(int i = 1; i <= n; i++) if(!a[i]) {
        int lo = 0, hi = (int)u.size() - 1, idx; 
        while(lo <= hi) {
            int mid = lo + hi >> 1; 
            vector<int> v = {i}; 
            for(int j = 0; j < mid; j++) 
                v.push_back(u[j]); 
            if(ask(v) == v.size()) 
                idx = mid, lo = mid + 1; 
            else hi = mid - 1; 
        } a[i] = a[u[idx]]; 
    }
    cout << 0; 
    for(int i = 1; i <= n; i++) 
        cout << " " << a[i];
    cout << endl;
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:11:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int x : v) cout << " " << x; cout << endl;
     ^~~
carnival.cpp:11:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int x : v) cout << " " << x; cout << endl;
                                      ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ask(v) == v.size()) 
            ~~~~~~~^~~~~~~~~~~
carnival.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < u.size(); i++) 
                    ~~^~~~~~~~~~
carnival.cpp:29:26: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             int mid = lo + hi >> 1; 
                       ~~~^~~~
carnival.cpp:33:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(ask(v) == v.size()) 
                ~~~~~~~^~~~~~~~~~~
carnival.cpp:36:25: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         } a[i] = a[u[idx]]; 
                         ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 504 KB Output is correct
2 Correct 9 ms 504 KB Output is correct
3 Correct 10 ms 504 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 9 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 528 KB Output is correct
2 Correct 10 ms 528 KB Output is correct
3 Correct 8 ms 528 KB Output is correct
4 Correct 7 ms 644 KB Output is correct
5 Correct 9 ms 644 KB Output is correct
6 Correct 7 ms 644 KB Output is correct
7 Correct 8 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 644 KB Output is correct
2 Correct 8 ms 644 KB Output is correct
3 Correct 10 ms 644 KB Output is correct
4 Correct 5 ms 644 KB Output is correct
5 Correct 7 ms 644 KB Output is correct
6 Correct 9 ms 644 KB Output is correct
7 Correct 6 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 644 KB Output is correct
2 Correct 4 ms 644 KB Output is correct
3 Correct 5 ms 644 KB Output is correct
4 Correct 5 ms 644 KB Output is correct
5 Correct 8 ms 644 KB Output is correct
6 Correct 5 ms 644 KB Output is correct
7 Correct 9 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 644 KB Output is correct
2 Correct 9 ms 644 KB Output is correct
3 Correct 6 ms 644 KB Output is correct
4 Correct 7 ms 644 KB Output is correct
5 Correct 6 ms 644 KB Output is correct
6 Correct 8 ms 644 KB Output is correct
7 Correct 5 ms 644 KB Output is correct