답안 #166689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166689 2019-12-03T13:26:06 Z rolimans 사육제 (CEOI14_carnival) C++14
100 / 100
23 ms 380 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX = 150;

int costumes[MAX];

int nat = 1;

int n;

bool hasRepeated(int s,int e, int ref){
    int res;
    if(s==e){
        cout << 2 << " " << ref << " " << s << endl;
        cin >> res;
        if(res==1){
         costumes[s] = costumes[ref];
            return true;
        }else return false;
    }else{
        int parts = e-s +1;
        cout << parts << " ";
        for(int i=s;i<=e;i++){
            cout << i;
            if(i!=e)
                cout<<" ";
            else
                cout << endl;
        }
        cin >> res;
        int mem = res;
        parts++;
        cout << parts << " " << ref << " ";
        for(int i=s;i<=e;i++){
            cout << i;
            if(i!=e)
                cout<<" ";
            else
                cout << endl;
        }
        cin >> res;
        return res==mem;
    }
}

void check(int s,int e,int ref){
    int fHalf;
    int sHalf;

    int c = e-s+1;
    if(c!=1){
        fHalf = e-(c/2);
        sHalf = fHalf+1;
    }else{
        fHalf = e;
        sHalf= e;
    }

    if(hasRepeated(s,fHalf,ref) && s!=fHalf){
        check(s,fHalf,ref);
    }
    if(hasRepeated(sHalf,e,ref) && sHalf!=e){
        check(sHalf,e,ref);
    }
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr),cout.tie(nullptr);

    cin >> n;

    for(int i=1;i<=n;i++){
        if(costumes[i]==0){
            costumes[i] = nat++;
            if(i!=n)
                check(i+1,n,i);
        }
    }

    cout << 0 << " ";

    for(int i=1;i<=n;i++){
        cout << costumes[i];
        if(i!=n){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 13 ms 248 KB Output is correct
3 Correct 16 ms 380 KB Output is correct
4 Correct 10 ms 248 KB Output is correct
5 Correct 8 ms 248 KB Output is correct
6 Correct 5 ms 248 KB Output is correct
7 Correct 21 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 248 KB Output is correct
2 Correct 14 ms 248 KB Output is correct
3 Correct 12 ms 248 KB Output is correct
4 Correct 13 ms 252 KB Output is correct
5 Correct 11 ms 376 KB Output is correct
6 Correct 6 ms 248 KB Output is correct
7 Correct 20 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 11 ms 248 KB Output is correct
3 Correct 13 ms 248 KB Output is correct
4 Correct 7 ms 248 KB Output is correct
5 Correct 13 ms 376 KB Output is correct
6 Correct 8 ms 376 KB Output is correct
7 Correct 21 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 376 KB Output is correct
2 Correct 18 ms 376 KB Output is correct
3 Correct 9 ms 248 KB Output is correct
4 Correct 10 ms 376 KB Output is correct
5 Correct 8 ms 248 KB Output is correct
6 Correct 10 ms 248 KB Output is correct
7 Correct 13 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 376 KB Output is correct
2 Correct 23 ms 248 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 20 ms 376 KB Output is correct
5 Correct 8 ms 248 KB Output is correct
6 Correct 7 ms 248 KB Output is correct
7 Correct 12 ms 376 KB Output is correct