답안 #257273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257273 2020-08-04T03:30:59 Z shrek12357 사육제 (CEOI14_carnival) C++14
100 / 100
9 ms 384 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <climits>
using namespace std;
 
const int nmax=155;
 
int ask(vector<int> v)
{
    cout<<v.size();
    for(auto k:v)cout<<" "<<k;
    cout<<endl;
    int ret;
    cin>>ret;
    return ret;
}
 
int output[nmax];
 
vector<int> my_merge(vector<int> v,int val)
{
    v.push_back(val);
    return v;
}
int main()
{
    int n;
    cin>>n;
 
    vector<int> diff={};
    for(int i=1;i<=n;i++)
    {
        if(ask(my_merge(diff,i))==diff.size()+1){diff.push_back(i);output[i]=diff.size();}
        else
        {
            vector<int> active=diff;
 
            while(active.size()>1)
            {
                vector<int> help[2];
 
                help[0]={};
                help[1]={};
 
                for(int j=0;j<active.size();j++)
                    help[j%2].push_back(active[j]);
 
                if(ask(my_merge(help[0],i))==help[0].size())active=help[0];
                else active=help[1];
            }
            output[i]=output[active[0]];
        }
    }
 
    cout<<0;for(int i=1;i<=n;i++)cout<<" "<<output[i];cout<<endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:37:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(ask(my_merge(diff,i))==diff.size()+1){diff.push_back(i);output[i]=diff.size();}
            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
carnival.cpp:49:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0;j<active.size();j++)
                             ~^~~~~~~~~~~~~~
carnival.cpp:52:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(ask(my_merge(help[0],i))==help[0].size())active=help[0];
                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 7 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 8 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 9 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 9 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 7 ms 256 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct