답안 #1008497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1008497 2024-06-26T13:35:42 Z VMaksimoski008 사육제 (CEOI14_carnival) C++17
100 / 100
5 ms 596 KB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

signed main() {
    int n;
    cin >> n;

    vector<int> diff;
    vector<int> v(n+1);
    v[1] = 1;
    diff.push_back(1);

    auto query = [&](vector<int> &vec) {
        cout << vec.size();
        for(int &el : vec) cout << " " << el;
        cout << endl;

        int ans;
        cin >> ans;
        return ans;
    };

    int id = 2;
    for(int i=2; i<=n; i++) {
        int x = diff.size();
        diff.push_back(i);
        if(query(diff) == diff.size()) {
            v[i] = id++;
            continue;
        }

        diff.pop_back();

        int l=0, r=diff.size()-1, p=r;
        while(l <= r) {
            int mid = (l + r) / 2;
            vector<int> vec;
            for(int j=0; j<=mid; j++) vec.push_back(diff[j]);
            vec.push_back(i);
            if(query(vec) == vec.size() - 1) p = mid, r = mid - 1;
            else l = mid + 1;
        }

        v[i] = v[diff[p]];
    }

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

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:40:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         if(query(diff) == diff.size()) {
      |            ~~~~~~~~~~~~^~~~~~~~~~~~~~
carnival.cpp:53:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |             if(query(vec) == vec.size() - 1) p = mid, r = mid - 1;
      |                ~~~~~~~~~~~^~~~~~~~~~~~~~~~~
carnival.cpp:38:13: warning: unused variable 'x' [-Wunused-variable]
   38 |         int x = diff.size();
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 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 2 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 4 ms 344 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 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 4 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 3 ms 344 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 596 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 3 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 3 ms 344 KB Output is correct
4 Correct 5 ms 440 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 3 ms 344 KB Output is correct