Submission #306523

# Submission time Handle Problem Language Result Execution time Memory
306523 2020-09-25T19:13:19 Z waterfall Carnival (CEOI14_carnival) C++11
100 / 100
8 ms 256 KB
#include<bits/stdc++.h>
using namespace std;

#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

int N;
int colors[152];

int32_t main()
{
    cin >> N;
    colors[1] = 1;
    vector<int> v;
    v.push_back(1);

    for(int i = 2; i <= N; i++)
    {
        //check if it is adding a new color
        cout << v.size() + 1;
        for(int j = 0; j < v.size(); j++)
        {
            cout << " " << v[j];
        }
        cout << " " << i << endl;

        int c;
        cin >> c;

        if(c > v.size())
        {
            v.push_back(i);
            colors[i] = v.size();
        }
        else
        {
            int lower = 0;
            int upper = v.size() - 1;
            while(lower != upper)
            {
                int mid = (lower + upper) / 2;
                cout << mid - lower + 2;
                for(int j = lower; j <= mid; j++)
                {
                    cout << " " << v[j];
                }
                cout << " " << i << endl;

                int c;
                cin >> c;

                if(c > (mid - lower + 1))
                {
                    lower = mid + 1;
                }
                else
                {
                    upper = mid;
                }
            }

            colors[i] = lower + 1;
        }
    }

    cout << 0;
    for(int i = 1; i <= N; i++)
    {
        cout << " " << colors[i];
    }
    return 0;
}


Compilation message

carnival.cpp: In function 'int32_t main()':
carnival.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = 0; j < v.size(); j++)
      |                        ~~^~~~~~~~~~
carnival.cpp:44:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(c > v.size())
      |            ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 256 KB Output is correct
2 Correct 4 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 3 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 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 4 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
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 7 ms 256 KB Output is correct
4 Correct 3 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 7 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 6 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 6 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 7 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 8 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 6 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 4 ms 256 KB Output is correct