Submission #220144

# Submission time Handle Problem Language Result Execution time Memory
220144 2020-04-07T06:40:50 Z MKopchev Carnival (CEOI14_carnival) C++14
100 / 100
12 ms 512 KB
#include<bits/stdc++.h>
using namespace std;

const int nmax=1e3+42;

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
        {
            //output[i] is within output[diff[j]]
            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:31: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:44:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0;j<active.size();j++)
                             ~^~~~~~~~~~~~~~
carnival.cpp:47:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(ask(my_merge(help[0],i))==help[0].size())active=help[0];
                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 7 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 7 ms 256 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 256 KB Output is correct
2 Correct 12 ms 256 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 10 ms 256 KB Output is correct
6 Correct 10 ms 384 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 256 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 10 ms 384 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 9 ms 384 KB Output is correct
4 Correct 7 ms 384 KB Output is correct
5 Correct 11 ms 384 KB Output is correct
6 Correct 11 ms 256 KB Output is correct
7 Correct 11 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 256 KB Output is correct
2 Correct 11 ms 256 KB Output is correct
3 Correct 8 ms 380 KB Output is correct
4 Correct 10 ms 384 KB Output is correct
5 Correct 11 ms 256 KB Output is correct
6 Correct 11 ms 512 KB Output is correct
7 Correct 8 ms 256 KB Output is correct