답안 #978172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978172 2024-05-09T01:47:13 Z AlphaMale06 사육제 (CEOI14_carnival) C++17
100 / 100
4 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back

int main()
{
    int n;
    cin >> n;
    vector<int> qry;
    qry.pb(1);
    int c[n+1];
    c[1]=1;
    for(int i=2; i<=n; i++){
        qry.pb(i);
        cout << qry.size();
        for(int e : qry)cout << " " << e;
        cout << endl;
        int ans;
        cin >> ans;
        if(ans==qry.size()){
            c[i]=qry.size();
        }
        else{
            qry.pop_back();
            int sz = qry.size();
            bool mark[sz];
            for(int j=0; j< sz; j++)mark[j]=0;
            int cnt=sz;
            while(cnt>1){
                int mk = cnt>>1;
                vector<int> qry1;
                vector<int> kolkogej;
                for(int j=0; j<sz; j++){
                    if(!mark[j]){
                        mk--;
                        qry1.pb(qry[j]);
                        kolkogej.pb(j);
                    }
                    if(mk==0)break;
                }
                cout << qry1.size()+1;
                for(int e : qry1)cout << " " << e;
                cout << " " << i << endl;
                int ans1;
                cin >> ans1;
                if(ans1==qry1.size()+1){
                    for(int e : kolkogej){
                        mark[e]=1;
                    }
                }
                else{
                    for(int j=0; j<sz; j++)mark[j]=1;
                    for(int e : kolkogej){
                        mark[e]=0;
                    }
                }
                cnt=0;
                for(int j=0; j< sz; j++){
                    if(!mark[j])cnt++;
                }
            }
            for(int j=0; j < sz; j++){
                if(!mark[j]){
                    c[i]=c[qry[j]];
                    break;
                }
            }
        }
    }
    cout << 0;
    for(int i=1; i<=n; i++)cout << " " << c[i];
    cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(ans==qry.size()){
      |            ~~~^~~~~~~~~~~~
carnival.cpp:48:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |                 if(ans1==qry1.size()+1){
      |                    ~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 432 KB Output is correct
5 Correct 1 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 3 ms 600 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 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 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 2 ms 436 KB Output is correct