답안 #989350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
989350 2024-05-28T03:47:51 Z hansenhe 사육제 (CEOI14_carnival) C++14
100 / 100
6 ms 864 KB
#include <bits/stdc++.h>
using namespace std;
vector<int> distinct;
string str = "";
bool good(int a, int mid, int num){ // from a to mid inclusive
    cout << mid - a + 2 << " ";
    str = "";
    for (int i = a - 1; i <= mid - 1; i++) {
        cout << distinct[i] << " ";
        str += to_string(distinct[i]); str += " ";
    }
    cout << num << "\n";
    str += to_string(num);
    cout.flush();
    int nwsz; cin >> nwsz;
    if (nwsz == mid - a + 2) return false;
    return true;
}
signed main(){
    ios::sync_with_stdio(false);
	cin.tie(nullptr);
    int n; cin >> n;
    vector<int> bad;
    for (int i = 1; i <= n; i++){
        str = "";
        int ip = distinct.size() + 1;
        cout << ip << " ";
        str = to_string(ip); str += " ";
        for (int x : distinct) {
            cout << x << " ";
            str += to_string(x); str += " ";
        }
        cout << i << "\n";
        str += to_string(i);
        cout.flush();
        int nwsz = 0; cin >> nwsz;
        if (nwsz == ip){
            distinct.push_back(i);
        } else {
            bad.push_back(i);
        }
    }
    map<int, vector<int>> mp;
    for (int i = 1; i <= distinct.size(); i++) mp[i].push_back(distinct[i - 1]);
    // we now have a list of all distinct costumes
    for (int k : bad){
        int a = 1, b = distinct.size();
        while (a != b){
            int mid = (a + b) / 2;
            if (good(a, mid, k)){
                b = mid;
            } else {
                a = mid + 1;
            }
        }
        mp[a].push_back(k);
    }
    cout << "0 ";
    vector<int> ans(n);
    for (auto p : mp){
        for (int x : p.second){
            ans[x - 1] = p.first;
        }
    }
    for (int x : ans) cout << x << " ";
    cout << "\n";
    cout.flush();
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 1; i <= distinct.size(); i++) mp[i].push_back(distinct[i - 1]);
      |                     ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 412 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 4 ms 600 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 2 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 864 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 4 ms 452 KB Output is correct
7 Correct 2 ms 344 KB Output is correct