답안 #705284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
705284 2023-03-03T18:59:10 Z lukameladze 사육제 (CEOI14_carnival) C++14
100 / 100
10 ms 340 KB
# include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define pii pair <int,int>
const int N = 3e5 + 5;
int le,ri,mid,pas[N],idx[N],a[N],pre,n;
vector <int> v,v1;
int ask(vector <int> vv) {
    cout<<vv.size()<<" ";
    for (int i = 0; i < vv.size(); i++) {
        cout<<vv[i]<<" ";
    }
    cout<<endl;
    int x;
    cin>>x;
    return x;
}
void go(vector <int> v) {
    int x = v.back();
    int ans = 0;
    le = 0; ri = (int)v.size() - 2;
    while (le <= ri) {
        int mid = (le + ri) / 2;
        vector <int> v1;
        for (int j = 0; j <= mid; j++) v1.pb(v[j]);
        v1.pb(x);
        if (ask(v1) == v1.size()) {
            le = mid + 1;
        } else {ans = mid; ri = mid - 1;}
    }
    pas[x] = pas[v[ans]];
    //cout<<x<<" ---> "<<pas[x]<<endl;
}
main() {
    std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n;
    v.pb(1); pre = 1;
    idx[pre] = 1;
    pas[1] = 1;
    for (int i = 2; i <= n; i++) {
        v.pb(i);
        if (ask(v) == pre) {
            go(v);
            v.pop_back();
        }
        else pre++, idx[pre] = i, pas[i] = pre;
    }
    cout<<0<<" ";
    for (int i = 1; i <= n; i++) {
        cout<<pas[i]<<" ";
    }
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < vv.size(); i++) {
      |                     ~~^~~~~~~~~~~
carnival.cpp: In function 'void go(std::vector<int>)':
carnival.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         if (ask(v1) == v1.size()) {
      |             ~~~~~~~~^~~~~~~~~~~~
carnival.cpp: At global scope:
carnival.cpp:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   36 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 4 ms 336 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 2 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 4 ms 336 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 8 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 4 ms 336 KB Output is correct
4 Correct 3 ms 336 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 6 ms 336 KB Output is correct
7 Correct 8 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 336 KB Output is correct
2 Correct 9 ms 336 KB Output is correct
3 Correct 10 ms 336 KB Output is correct
4 Correct 7 ms 336 KB Output is correct
5 Correct 5 ms 336 KB Output is correct
6 Correct 4 ms 340 KB Output is correct
7 Correct 3 ms 336 KB Output is correct