Submission #48796

# Submission time Handle Problem Language Result Execution time Memory
48796 2018-05-18T19:31:25 Z alex99 Carnival (CEOI14_carnival) C++14
100 / 100
25 ms 588 KB
#include <iostream>
#include <vector>
using namespace std;
int N;
int Res[155];
vector <int> Pos;
int ask(vector <int> V)
{
    cout << V.size() << " ";
    for(int i = 0; i < V.size(); i++)
        cout << V[i] << " ";
    cout << endl;
    int ans;
    cin >> ans;
    return ans;
}
int binS(int pos)
{
    int left = 0, right = Pos.size() - 1, sol = 0, mid;
    while(left <= right)
    {
        mid = (left + right) / 2;
        vector <int> V;
        for(int j = 0; j <= mid; j++)
            V.push_back(Pos[j]);
        V.push_back(pos);
        int nb = ask(V);
        if(nb == V.size())
        {
            left = mid + 1;
        }
        else
        {
            sol = mid;
            right = mid - 1;
        }
    }
    return sol + 1;
}
void Solve()
{
    Res[1] = 1;
    Pos.push_back(1);
    int cnt = 1;
    for(int i = 2; i <= N; i++)
    {
        vector <int> V;
        for(int j = 1; j <= i; j++)
            V.push_back(j);
        int nb = ask(V);
        if(nb == cnt + 1)
        {
            cnt++;
            Res[i] = cnt;
            Pos.push_back(i);
            continue;
        }
        Res[i] = binS(i);
    }
    cout << "0 ";
    for(int i = 1; i <= N; i++)
        cout << Res[i] << " ";
    cout << "\n";
}
int main()
{
    cin >> N;
    Solve();
    return 0;
}

Compilation message

carnival.cpp: In function 'int ask(std::vector<int>)':
carnival.cpp:10:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < V.size(); i++)
                    ~~^~~~~~~~~~
carnival.cpp: In function 'int binS(int)':
carnival.cpp:28:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(nb == V.size())
            ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 296 KB Output is correct
2 Correct 7 ms 436 KB Output is correct
3 Correct 6 ms 436 KB Output is correct
4 Correct 4 ms 572 KB Output is correct
5 Correct 5 ms 572 KB Output is correct
6 Correct 4 ms 572 KB Output is correct
7 Correct 7 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 572 KB Output is correct
2 Correct 6 ms 580 KB Output is correct
3 Correct 5 ms 588 KB Output is correct
4 Correct 5 ms 588 KB Output is correct
5 Correct 6 ms 588 KB Output is correct
6 Correct 5 ms 588 KB Output is correct
7 Correct 5 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 588 KB Output is correct
2 Correct 10 ms 588 KB Output is correct
3 Correct 10 ms 588 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Correct 10 ms 588 KB Output is correct
6 Correct 9 ms 588 KB Output is correct
7 Correct 9 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 588 KB Output is correct
2 Correct 7 ms 588 KB Output is correct
3 Correct 5 ms 588 KB Output is correct
4 Correct 4 ms 588 KB Output is correct
5 Correct 9 ms 588 KB Output is correct
6 Correct 7 ms 588 KB Output is correct
7 Correct 8 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 588 KB Output is correct
2 Correct 6 ms 588 KB Output is correct
3 Correct 13 ms 588 KB Output is correct
4 Correct 11 ms 588 KB Output is correct
5 Correct 25 ms 588 KB Output is correct
6 Correct 7 ms 588 KB Output is correct
7 Correct 8 ms 588 KB Output is correct