Submission #842415

# Submission time Handle Problem Language Result Execution time Memory
842415 2023-09-02T20:54:06 Z vxxwu Carnival (CEOI14_carnival) C++17
100 / 100
6 ms 952 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

#define MAXN 150
#define ll long long
#define int ll
#define max max<int>
#define min min<int>
#define f first
#define s second

typedef pair<int, int> pii;

int costume[MAXN+1];
int costume_pointer[MAXN+1];
int costumes=1;
int diff;

void binary_search(vector<int> query, int index){
    vector<int> temp;
    for(int i=0; i<query.size()/2; i++){
        temp.emplace_back(query[i]);
    }
    cout<<temp.size()+1<<" ";
    for(int j:temp){
        cout<<j<<" ";
    }
    cout<<index<<endl;

    cin>>diff;
    if(diff==temp.size()){
        if(diff==1){
            costume[index]=costume[temp[0]];
            return;
        }
        binary_search(temp, index);
        return;
    }

    temp.clear();
    for(int i=query.size()/2; i<query.size(); i++){
        temp.emplace_back(query[i]);
    }
    cout<<temp.size()+1<<" ";
    for(int j:temp){
        cout<<j<<" ";
    }
    cout<<index<<endl;

    cin>>diff;
    if(diff==temp.size()){
        if(diff==1){
            costume[index]=costume[temp[0]];
            return;
        }
        binary_search(temp, index);
        return;
    }
}

int32_t main() {
//    freopen("split.in", "r", stdin);
//    freopen("split.out", "w", stdout);

    int n; cin>>n;
    costume[1]=1;
    costume_pointer[1]=1;

    for(int i=2; i<=n; i++) {
        vector<int> query;
        for(int j=1; j<=costumes; j++){
            query.emplace_back(costume_pointer[j]);
        }

        cout<<costumes+1<<" ";
        for(int j:query){
            cout<<j<<" ";
        }
        cout<<i<<endl;

        cin>>diff;
        if(diff==costumes+1){
            costumes++;
            costume[i]=costumes;
            costume_pointer[costumes]=i;
            continue;
        }
        else{
            binary_search(query, i);
        }
    }

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

Compilation message

carnival.cpp: In function 'void binary_search(std::vector<long long int>, long long int)':
carnival.cpp:25:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(int i=0; i<query.size()/2; i++){
      |                  ~^~~~~~~~~~~~~~~
carnival.cpp:35:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if(diff==temp.size()){
      |        ~~~~^~~~~~~~~~~~~
carnival.cpp:45:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=query.size()/2; i<query.size(); i++){
      |                               ~^~~~~~~~~~~~~
carnival.cpp:55:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     if(diff==temp.size()){
      |        ~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 344 KB Output is correct
2 Correct 4 ms 608 KB Output is correct
3 Correct 3 ms 696 KB Output is correct
4 Correct 2 ms 700 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 6 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 436 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 2 ms 696 KB Output is correct
5 Correct 3 ms 444 KB Output is correct
6 Correct 3 ms 436 KB Output is correct
7 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 704 KB Output is correct
4 Correct 2 ms 448 KB Output is correct
5 Correct 3 ms 436 KB Output is correct
6 Correct 3 ms 600 KB Output is correct
7 Correct 4 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 4 ms 856 KB Output is correct
4 Correct 4 ms 952 KB Output is correct
5 Correct 3 ms 696 KB Output is correct
6 Correct 2 ms 692 KB Output is correct
7 Correct 2 ms 704 KB Output is correct