답안 #229981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229981 2020-05-07T12:54:00 Z nicolaalexandra 사육제 (CEOI14_carnival) C++14
100 / 100
31 ms 384 KB
#include <bits/stdc++.h>
#define DIM 200
using namespace std;

int v[DIM],w[DIM],sol[DIM],f[DIM];
int n,k,i,j,el;

int query (){
    int ans;
    cout<<el<<" ";
    for (int i=1;i<=el;i++)
        cout<<w[i]<<" ";
    cout<<endl;
    cin>>ans;
    cout<<endl;

    return ans;
}
int verif (int x, int y, int poz){
    el = 0;
    for (int i=x;i<=y;i++)
        w[++el] = v[i];
    w[++el] = poz;
    if (query() == y-x+1)
        return 1;
    return 0;
}
int main (){

    cin>>n;
    v[++k] = 1;
    f[1] = sol[1] = 1;

    for (i=2;i<=n;i++){
        /// mai intai verific daca e o culoare noua
        el = 0;
        for (j=1;j<=i;j++)
            w[++el] = j;
        int val = query ();
        f[i] = val;

        if (val > f[i-1]){
            /// inseamna ca am o noua culoare
            v[++k] = i;
            sol[i] = k;
        } else {
            /// o caut binar ish in culorile deja existente
            int st = 1, dr = k;
            while (st <= dr){
                int mid = (st+dr)>>1;
                if (verif (mid,mid,i)){
                    sol[i] = mid;
                    break;
                }

                if (verif (st,mid,i))
                    dr = mid-1;
                else st = mid+1;
            }
        }
    }

    cout<<"0 ";
    for (i=1;i<=n;i++)
        cout<<sol[i]<<" ";
    cout<<endl;


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 13 ms 256 KB Output is correct
3 Correct 12 ms 256 KB Output is correct
4 Correct 8 ms 256 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 8 ms 384 KB Output is correct
7 Correct 15 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 384 KB Output is correct
2 Correct 18 ms 256 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 15 ms 256 KB Output is correct
7 Correct 15 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 14 ms 256 KB Output is correct
3 Correct 13 ms 256 KB Output is correct
4 Correct 8 ms 384 KB Output is correct
5 Correct 13 ms 256 KB Output is correct
6 Correct 13 ms 384 KB Output is correct
7 Correct 14 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 384 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 10 ms 256 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
5 Correct 14 ms 256 KB Output is correct
6 Correct 15 ms 256 KB Output is correct
7 Correct 15 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 384 KB Output is correct
2 Correct 31 ms 256 KB Output is correct
3 Correct 14 ms 256 KB Output is correct
4 Correct 12 ms 384 KB Output is correct
5 Correct 12 ms 384 KB Output is correct
6 Correct 12 ms 256 KB Output is correct
7 Correct 9 ms 384 KB Output is correct