Submission #752667

# Submission time Handle Problem Language Result Execution time Memory
752667 2023-06-03T11:56:47 Z DeathIsAwe Carnival (CEOI14_carnival) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
using namespace std;

int binsearch(int c,vector<int>& uppl) {
    int org=c;
    int a=0,b=c/2,output;
    while (a!=b) {
        cout << c-b+1 << ' ';
        for (int i=b;i<c;i++) {
            cout << uppl[i] << ' ';
        }
        cout << uppl[org] << ' '; cin >> output;
        if (output<c-b) {
            a=b; b=(c-a)/2+a;
        } else {
            c=b; b=(c-a)/2+a;
        }
    }
    return b;
}

int main() {
    vector<vector<int>> samekind(151); int n,output; cin >> n;
    vector<int> ans(n+1);
    vector<int> uppl;
    for (int i=0;i<n;i++) {
        uppl.push_back(i+1);
    }

    int canceler=0,searchres;
    for (int i=0;i<n;i++) {
        cout << i+1-canceler << ' ';
        for (int j=0;j<i-canceler;j++) {
            cout << uppl[j] << ' ';
        }
        cout << '\n';
        cin >> output;
        if (output<i+1-canceler) {
            searchres=binsearch(i-canceler,uppl);
            samekind[uppl[searchres]].push_back(uppl[i-canceler]);
            uppl.erase(uppl.begin()+i-canceler);
            canceler+=1;
        }
    }
    for (int i=0;i<uppl.size();i++) {
        ans[uppl[i]]=i+1;
        for (auto &j: samekind[uppl[i]]) {
            ans[j]=i+1;
        }
    }
    cout << 0 << ' ';
    for (int i=1;i<n+1;i++) {
        cout << ans[i] << ' ';
    }
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i=0;i<uppl.size();i++) {
      |                  ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -