Submission #1085718

# Submission time Handle Problem Language Result Execution time Memory
1085718 2024-09-08T15:35:28 Z LeonidCuk Carnival (CEOI14_carnival) C++17
0 / 100
70 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
vector<int>v;
bool check2(int l,int r,int k)
{
    cout<<r-l+2<<" ";
    for(int i=l;i<=r;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<k<<endl;
    int a;
    cin>>a;
    if(a==r-l+2)
    {
        return true;
    }
    return false;
}
bool check(int k)
{
    cout<<v.size()+1<<" ";
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<k<<endl;
    int a;
    cin>>a;
    if(a==v.size()+1)
    {
        return true;
    }
    return false;
}
int main()
{
    int n,cnt=1;
    cin>>n;
    vector<int>res(n+1);
    res[1]=cnt++;
    v.push_back(1);
    for(int i=2;i<=n;i++)
    {
        if(check(i))
        {
            v.push_back(i);
            res[i]=cnt++;
        }
        else
        {
            int l=0,r=v.size()-1;
            while(l<r)
            {
                int m=l+r/2;
                if(check2(l,m,i))
                {
                    l=m+1;
                }
                else
                {
                    r=m;
                }
            }
            res[i]=res[v[l]];
        }
    }
    cout<<"0 ";
    for(int i=1;i<=n;i++)
    {
        cout<<res[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Compilation message

carnival.cpp: In function 'bool check(int)':
carnival.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
carnival.cpp:30:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if(a==v.size()+1)
      |        ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 596 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 70 ms 412 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 66 ms 408 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Runtime error 53 ms 412 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -