답안 #1042663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042663 2024-08-03T09:17:17 Z Rafiullah 사육제 (CEOI14_carnival) C++17
100 / 100
12 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
const int N = (1<<19);
const long long mod = 1e9+7;
const long long mod1 = 998244353;
int query(int n,int k=-1){
    int col;
    if(k == -1){
        cout<<n<<endl;
        for(int i = 1;i<=n ;i ++){
            cout<<i<<" ";
        }
        cout<<endl;
        cin >> col;
    }
    else{
        cout<<n+1<<endl;
        for(int i = 1;i<= n; i++){
            cout<<i<<" ";
        }
        cout<<k<<endl;
        cin >> col;
    }
    return col;
}
void solve(){
    int n;cin >> n;
    vector<int> c(n+1);
    c[1] = 1;
    vector<int> q(n+1);
    q[1] = 1;
    int t = 2;
    for(int i = 2;i<=n ;i ++){
        q[i] = query(i);
        int low = 1;
        int high = i-1;
        while(low<=high){
            int mid = (low+high)/2;
            int o = query(mid,i);
            if(o == q[mid])high = mid-1;
            else low = mid+1;
        }
        if(low<i){
            c[i] = c[low];
        }
        else{
            c[i] = t;
            t++;
        }
    }
    cout<<0<<" ";
    for(int i = 1;i<= n ;i++){
        cout<<c[i]<<" ";
    }
    cout<<endl;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    long long t=1;
    // cin >> t;
    cout<<setprecision(16);
    while(t--){
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 7 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 11 ms 344 KB Output is correct
5 Correct 5 ms 340 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 7 ms 344 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
4 Correct 8 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 8 ms 344 KB Output is correct
4 Correct 12 ms 344 KB Output is correct
5 Correct 9 ms 344 KB Output is correct
6 Correct 9 ms 344 KB Output is correct
7 Correct 9 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 344 KB Output is correct
2 Correct 8 ms 344 KB Output is correct
3 Correct 10 ms 344 KB Output is correct
4 Correct 7 ms 344 KB Output is correct
5 Correct 11 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 10 ms 344 KB Output is correct