Submission #333979

# Submission time Handle Problem Language Result Execution time Memory
333979 2020-12-08T04:23:12 Z updown1 Carnival (CEOI14_carnival) C++17
100 / 100
9 ms 364 KB
#include <iostream>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int costume[n+1];
    map<int,int> matched;
    int counter = 0;
    for(int i=1; i<=n; i++)
    {
        cout << matched.size()+1;
        for(int j=1; j<=matched.size(); j++)
        {
            cout << " " << matched[j];
        }
        cout << " " << i << endl;
        int newcount;
        cin >> newcount;
        if(newcount>counter)
        {
            matched[newcount] = i;
            costume[i] = newcount;
            counter++;
            continue;
        }
        int a = 1;
        int b = matched.size();
        while(a!=b)
        {
            int mid = (a+b)/2;
            cout << mid-a+2;
            for(int j=a; j<=mid; j++)
            {
                cout << " " << matched[j];
            }
            cout << " " << i << endl;
            int newval;
            cin >> newval;
            if(newval==(mid-a+1))
                b = mid;
            else
                a = mid+1;
        }
        costume[i] = a;
    }
    cout << 0;
    for(int i=1; i<=n; i++)
    {
        cout << " " << costume[i];
    }
    cout << endl;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::map<int, int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |         for(int j=1; j<=matched.size(); j++)
      |                      ~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 5 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 9 ms 364 KB Output is correct
3 Correct 4 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 6 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 6 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 7 ms 364 KB Output is correct
6 Correct 4 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 6 ms 364 KB Output is correct
4 Correct 5 ms 364 KB Output is correct
5 Correct 8 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 8 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 7 ms 364 KB Output is correct
4 Correct 6 ms 364 KB Output is correct
5 Correct 7 ms 364 KB Output is correct
6 Correct 6 ms 364 KB Output is correct
7 Correct 5 ms 364 KB Output is correct