Submission #579143

# Submission time Handle Problem Language Result Execution time Memory
579143 2022-06-18T12:20:51 Z Jarif_Rahman Carnival (CEOI14_carnival) C++17
100 / 100
51 ms 312 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int ask(vector<int> s){
    cout << s.size() << " ";
    for(int x: s) cout << x << " ";
    cout << "\n";
    int x; cin >> x;
    return x;
}

int main(){
    setbuf(stdout, NULL);

    int n; cin >> n;
    int c = 0;

    vector<int> ans(n), s;

    for(int i = 1; i <= n; i++){
        s.pb(i);
        if(ask(s) != c){
            c++;
            ans[i-1] = c;
            continue;
        }
        s.pop_back();

        int a = 0, b = c-1;
        while(a < b){
            int md = (a+b)/2;
            vector<int> ss(s.begin(), s.begin()+md+1);
            ss.pb(i);
            if(ask(ss) == ss.size()) a = md+1;
            else b = md;
        }

        ans[i-1] = a+1;
    }

    cout << "0 ";
    for(int x: ans) cout << x << " ";
    cout << "\n";
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             if(ask(ss) == ss.size()) a = md+1;
      |                ~~~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 17 ms 208 KB Output is correct
3 Correct 19 ms 208 KB Output is correct
4 Correct 13 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 4 ms 208 KB Output is correct
7 Correct 19 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 28 ms 208 KB Output is correct
3 Correct 14 ms 208 KB Output is correct
4 Correct 29 ms 300 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 24 ms 208 KB Output is correct
4 Correct 30 ms 208 KB Output is correct
5 Correct 12 ms 208 KB Output is correct
6 Correct 14 ms 208 KB Output is correct
7 Correct 17 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 41 ms 288 KB Output is correct
4 Correct 28 ms 300 KB Output is correct
5 Correct 19 ms 208 KB Output is correct
6 Correct 12 ms 208 KB Output is correct
7 Correct 25 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 51 ms 304 KB Output is correct
4 Correct 24 ms 312 KB Output is correct
5 Correct 23 ms 292 KB Output is correct
6 Correct 14 ms 296 KB Output is correct
7 Correct 19 ms 208 KB Output is correct