Submission #600101

# Submission time Handle Problem Language Result Execution time Memory
600101 2022-07-20T13:02:58 Z MasterTaster Carnival (CEOI14_carnival) C++14
100 / 100
18 ms 344 KB
#include <iostream>
#include <vector>

#define pb push_back
#define MAXN 155

using namespace std;

int n, prosli[MAXN], ress[MAXN];
vector<int> novi;

bool check(int k, int i)
{
    cout<<k+1<<" ";
    for (int j=0; j<=k; j++) cout<<novi[j]<<" ";
    cout<<endl;
    int cnt1; cin>>cnt1;

    cout<<k+2<<" ";
    for (int j=0; j<=k; j++) cout<<novi[j]<<" ";
    cout<<i<<endl;
    int cnt2; cin>>cnt2;
    return (cnt1==cnt2);
}

int main() {
    cin>>n;

    int cnt=1;
    novi.pb(1);
    for (int i=2; i<=n; i++)
    {
        vector<int> sta;
        for (int j=1; j<=i; j++) sta.pb(j);
        cout<<sta.size()<<" ";
        for (int i=0; i<sta.size(); i++) cout<<sta[i]<<" ";
        cout<<endl;
        int tren; cin>>tren;
        if (tren>cnt)
        {
            prosli[i]=0;
            cnt=tren;
            novi.pb(i);
        }
        else
        {
            int l=0, r=novi.size()-1, gde=-1;
            while (l<=r)
            {
                int mid=l+(r-l)/2;
                if (check(mid, i))
                {
                    r=mid-1;
                    gde=mid;
                }
                else
                    l=mid+1;
            }
            prosli[i]=novi[gde];
        }
    }

    int col=1;
    for (int i=1; i<=n; i++)
    {
        if (prosli[i]==0) { ress[i]=col++; }
        else ress[i]=ress[prosli[i]];
    }

    cout<<0<<" ";
    for (int i=1; i<=n; i++) cout<<ress[i]<<" ";
    cout<<endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int i=0; i<sta.size(); i++) cout<<sta[i]<<" ";
      |                       ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 288 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 6 ms 300 KB Output is correct
7 Correct 18 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 304 KB Output is correct
2 Correct 14 ms 208 KB Output is correct
3 Correct 7 ms 300 KB Output is correct
4 Correct 4 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 11 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 296 KB Output is correct
2 Correct 9 ms 304 KB Output is correct
3 Correct 16 ms 304 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 8 ms 216 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 13 ms 280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 300 KB Output is correct
2 Correct 11 ms 304 KB Output is correct
3 Correct 6 ms 208 KB Output is correct
4 Correct 3 ms 208 KB Output is correct
5 Correct 10 ms 336 KB Output is correct
6 Correct 8 ms 304 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 12 ms 208 KB Output is correct
3 Correct 12 ms 304 KB Output is correct
4 Correct 10 ms 304 KB Output is correct
5 Correct 10 ms 304 KB Output is correct
6 Correct 7 ms 308 KB Output is correct
7 Correct 4 ms 208 KB Output is correct