답안 #995869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
995869 2024-06-10T03:18:13 Z khanhtb 사육제 (CEOI14_carnival) C++14
100 / 100
5 ms 460 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define pf push_front
#define vi vector<ll>
#define vii vector<vi>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()
#define fi first
#define se second
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e18;
const ll base = 31;
const ll blocksz = 320;
const ll N = 2e5+8;
const ll buff = 1e5+1;
ll a[N],n;
ll ask(vi a){
    cout << a.size() << " ";
    for(ll i:a) cout << i << " ";
    cout << endl;
    ll res;cin >> res;
    return res;
}
void solve(){
    cin >> n;
    vector<ll> ind;
    a[1] = 1;
    ind.pb(1);
    ll cntcol = 1;
    for(ll i = 2; i <= n; i++){
        vi qr = ind;
        qr.pb(i);
        ll c = ask(qr);
        if(c == cntcol+1){
            a[i] = ++cntcol;
            ind.pb(i);
        }
        else{
            ll l = 0, r = (ll)ind.size()-1;
            while(l < r){
                ll m = l+r>>1;
                qr.clear();
                for(ll j = l; j <= m; j++) qr.pb(ind[j]);
                qr.pb(i);
                c = ask(qr);
                if(c == m-l+2){
                    l = m+1;
                }
                else r = m;
            }
            a[i] = a[ind[r]];
        }
    } 
    cout << "0 ";
    for(ll i = 1; i <= n; i++) cout << a[i] << " ";
}
signed main(){
    // ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // if(fopen("test.inp","r")){
    //     freopen("test.inp","r",stdin);
    //     freopen("test.out","w",stdout);
    // }
    ll T = 1;
    // cin >> T;
    for(ll i = 1; i <= T; i++){
        solve();
        if(i < T) cout << '\n';
    }
}

Compilation message

carnival.cpp: In function 'void solve()':
carnival.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |                 ll m = l+r>>1;
      |                        ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 4 ms 440 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 4 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 3 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 344 KB Output is correct