답안 #239282

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239282 2020-06-15T08:01:28 Z aggu_01000101 사육제 (CEOI14_carnival) C++14
100 / 100
13 ms 384 KB
#include <bits/stdc++.h>
#define int long long
#define INF 1000000000000000
#define lchild(i) (i*2 + 1)
#define rchild(i) (i*2 + 2)
#define mid(l, u) ((l+u)/2)
#define x(p) p.first
#define y(p) p.second
#define MOD 998244353
using namespace std;
int q(vector<int> &curr, int i, int l, int r){
    cout<<((r-l+1) + 1)<<" ";
    for(int j = l;j<=r;j++) cout<<curr[j]<<" ";
    cout<<i<<endl;
    int tr;
    cin>>tr;
    return tr;
}
signed main(){
    int n;
    cin>>n;
    int arr[n+1];
    int nextdist = 2;
    arr[1] = 1;
    vector<int> curr = {1};
    //curr contains all distinct 'dresses' between 1 and i-1
    //If i is distinct, we add it to curr
    for(int i = 2;i<=n;i++){
        int dist = q(curr, i, 0, curr.size()-1);
        if(dist == nextdist){
            arr[i] = nextdist++;
            curr.push_back(i);
            continue;
        }
        //There is a duplicate
        int lo = 0;
        int hi = curr.size() - 1;
        while(lo<hi){
            int mid = mid(lo, hi);
            dist = q(curr, i, lo, mid);
            if(dist == ((mid - lo + 1) + 1)){
                lo = mid + 1;
                continue;
            }
            else hi = mid;
        }

        //lo is the index of the duplicate
        //cout<<"i is same as "<<lo<<endl;
        arr[i] = arr[curr[lo]];
    }
    cout<<"0 ";
    for(int i = 1;i<n;i++) cout<<arr[i]<<" ";
    cout<<arr[n]<<endl;
}
//2 1 2 3 1
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 256 KB Output is correct
2 Correct 10 ms 256 KB Output is correct
3 Correct 9 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 9 ms 384 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 13 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 12 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 8 ms 256 KB Output is correct
5 Correct 10 ms 256 KB Output is correct
6 Correct 9 ms 256 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 11 ms 256 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 10 ms 256 KB Output is correct
6 Correct 11 ms 256 KB Output is correct
7 Correct 11 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 8 ms 256 KB Output is correct
4 Correct 7 ms 256 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 11 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 7 ms 372 KB Output is correct
5 Correct 10 ms 372 KB Output is correct
6 Correct 8 ms 256 KB Output is correct
7 Correct 7 ms 384 KB Output is correct