답안 #944734

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944734 2024-03-13T04:13:07 Z wii 사육제 (CEOI14_carnival) C++17
100 / 100
4 ms 1204 KB
#include <bits/stdc++.h>
using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;

#define int ll
typedef pair<int, int> pii;

#define lx (id << 1)
#define rx (lx | 1)
#define gcd __gcd
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define bit(i, mask) ((mask) >> (i) & 1)
#define reset(x, val) memset(x, val, sizeof(x))
#define foru(i,a,b) for(int i = (a); i <= (b); ++i)
#define ford(i,a,b) for(int i = (a); i >= (b); --i)
#define FastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

template<typename T> bool maximize(T &res, const T &val) { if (res < val) { res = val; return true; } return false; }
template<typename T> bool minimize(T &res, const T &val) { if (val < res) { res = val; return true; } return false; }

const ll Linf = 0x3f3f3f3f3f3f3f3f;
const int Inf = 0x3f3f3f3f;
const ll Mod = 1e9 + 7;
const ll Mod2 = ll(1e9) + 9;
const int Lim = 1e6 + 5;
const int inv6 = 166666668;

/// ====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====

const int base = 3;
const int N = 150 + 5;
const int K = log2(N) + 1;
const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};
const int block_size = sqrt(2e9) + 2;

vector<int> adj[N];
int res[N];

int ask(vector<int> s) {
    cout << s.size() << " ";
    for (int x: s) cout << x << " ";
    cout << endl;

    int ans;
    cin >> ans;

    return ans;
}

void solve() {
    int n;
    cin >> n;

    vector<int> cur;
    function<void(int)> query = [&](int u) {
        int l = 1, r = cur.size();
        while (l <= r) {
            int mid = (l + r) >> 1;
            vector<int> s(cur.begin(), cur.begin() + mid);
            s.push_back(u);

            if (ask(s) == s.size())
                l = mid + 1;
            else
                r = mid - 1;
        }

        // cout << " -> " << u << " " << cur[l - 1] << endl;

        adj[cur[l - 1]].push_back(u);
    };

    foru(i, 1, n) {
        cur.push_back(i);
        if (ask(cur) != cur.size()) {
            cur.pop_back();
            query(i);
        }
    }

    int ptr = 0;
    for (int x: cur) {
        ++ptr;
        res[x] = ptr;

        for (int u: adj[x])
            res[u] = ptr;
    }

    cout << 0 << " ";
    foru(i, 1, n)
        cout << res[i] << " ";
    cout << endl;
}

signed main() {
    #define task ""
    if (fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}

    int ntest = 1;
    // cin >> ntest;
    while (ntest--) {
        //cout << "Case " << q << ": " << "\n";
        solve();
    }

    return 0;
}

/**  /\_/\
 *  (= ._.)
 *  / >TL \>AC
**/

Compilation message

carnival.cpp: In lambda function:
carnival.cpp:67:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if (ask(s) == s.size())
      |                 ~~~~~~~^~~~~~~~~~~
carnival.cpp: In function 'void solve()':
carnival.cpp:80:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |         if (ask(cur) != cur.size()) {
      |             ~~~~~~~~~^~~~~~~~~~~~~
carnival.cpp: In function 'int main()':
carnival.cpp:104:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  104 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:105:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 444 KB Output is correct
2 Correct 3 ms 436 KB Output is correct
3 Correct 2 ms 460 KB Output is correct
4 Correct 2 ms 692 KB Output is correct
5 Correct 2 ms 440 KB Output is correct
6 Correct 1 ms 436 KB Output is correct
7 Correct 3 ms 696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 444 KB Output is correct
2 Correct 4 ms 440 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
4 Correct 2 ms 700 KB Output is correct
5 Correct 3 ms 440 KB Output is correct
6 Correct 2 ms 436 KB Output is correct
7 Correct 3 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 444 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 4 ms 464 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 2 ms 436 KB Output is correct
6 Correct 3 ms 696 KB Output is correct
7 Correct 3 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 440 KB Output is correct
2 Correct 3 ms 436 KB Output is correct
3 Correct 2 ms 1204 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 3 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 436 KB Output is correct
2 Correct 3 ms 436 KB Output is correct
3 Correct 3 ms 440 KB Output is correct
4 Correct 3 ms 712 KB Output is correct
5 Correct 3 ms 692 KB Output is correct
6 Correct 2 ms 948 KB Output is correct
7 Correct 2 ms 692 KB Output is correct