Submission #396257

# Submission time Handle Problem Language Result Execution time Memory
396257 2021-04-29T15:49:22 Z Victor Carnival (CEOI14_carnival) C++17
100 / 100
18 ms 328 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)

#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back

#define umap unordered_map
#define uset unordered_set

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;

const int INF = 1000000007;

vi ans;
int cur;

int binsearch(vi party) {
    if (sz(party) == 1)
        return ans[party[0]];

    vi next;
    rep(i, 0, sz(party) >> 1) next.push_back(party[i]);
    next.pb(cur);

    cout << sz(next);
    trav(person, next) cout << ' ' << person + 1;
    cout << endl;

    int c1;
    cin >> c1;

    next.pop_back();
    cout << sz(next);
    trav(person, next) cout << ' ' << person + 1;
    cout << endl;

    int c2;
    cin >> c2;

    if (c2 < c1) {
        next.clear();
        rep(i, sz(party) >> 1, sz(party)) next.push_back(party[i]);
    }

    return binsearch(next);
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    ans.resize(n);
    vi party;
    rep(i, 0, n) {
        int costumes;

        party.pb(i);
        cout<<sz(party);
        trav(person,party)cout<<' '<<person+1;
        cout<<endl;
        cin>>costumes;

        if (costumes==sz(party)) {
            ans[i] = sz(party);
            continue;
        }

        party.pop_back();
        cur = i;
        ans[i] = binsearch(party);
    }

    cout<<0;
    rep(i,0,n)cout<<' '<<ans[i];
    cout<<endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int binsearch(vi)':
carnival.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
carnival.cpp:33:5: note: in expansion of macro 'rep'
   33 |     rep(i, 0, sz(party) >> 1) next.push_back(party[i]);
      |     ^~~
carnival.cpp:5:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 | #define rep(i, a, b) for (int i = a; i < (b); ++i)
      |                                        ^
carnival.cpp:53:9: note: in expansion of macro 'rep'
   53 |         rep(i, sz(party) >> 1, sz(party)) next.push_back(party[i]);
      |         ^~~
carnival.cpp: In function 'int main()':
carnival.cpp:76:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         if (costumes==sz(party)) {
      |                     ^
# Verdict Execution time Memory Grader output
1 Correct 9 ms 328 KB Output is correct
2 Correct 15 ms 204 KB Output is correct
3 Correct 9 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 7 ms 200 KB Output is correct
6 Correct 4 ms 200 KB Output is correct
7 Correct 14 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 200 KB Output is correct
2 Correct 18 ms 200 KB Output is correct
3 Correct 6 ms 200 KB Output is correct
4 Correct 6 ms 200 KB Output is correct
5 Correct 5 ms 200 KB Output is correct
6 Correct 10 ms 200 KB Output is correct
7 Correct 10 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 12 ms 200 KB Output is correct
3 Correct 11 ms 200 KB Output is correct
4 Correct 4 ms 308 KB Output is correct
5 Correct 12 ms 200 KB Output is correct
6 Correct 8 ms 200 KB Output is correct
7 Correct 16 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 204 KB Output is correct
2 Correct 9 ms 200 KB Output is correct
3 Correct 9 ms 200 KB Output is correct
4 Correct 4 ms 204 KB Output is correct
5 Correct 14 ms 200 KB Output is correct
6 Correct 7 ms 312 KB Output is correct
7 Correct 16 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 200 KB Output is correct
2 Correct 14 ms 200 KB Output is correct
3 Correct 12 ms 200 KB Output is correct
4 Correct 11 ms 200 KB Output is correct
5 Correct 9 ms 200 KB Output is correct
6 Correct 6 ms 200 KB Output is correct
7 Correct 5 ms 200 KB Output is correct