답안 #919524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919524 2024-02-01T04:36:22 Z Alihan_8 사육제 (CEOI14_carnival) C++17
20 / 100
64 ms 596 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define int long long

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
    bool flag = false;
    if ( u > v ){
        u = v; flag |= true;
    }
    return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
    bool flag = false;
    if ( u < v ){
        u = v; flag |= true;
    }
    return flag;
}

struct Dsu{
    // 0 - indexed
    vector <int> fa, sz;
    Dsu(int m){
        fa.resize(m);
        sz.resize(m);
        for ( int i = 0; i < m; i++ ){
            fa[i] = i; sz[i] = 1;
        }
    }
    int get(int x){
        return (x == fa[x] ? x : fa[x] = get(fa[x]));
    }
    bool merge(int u, int v){
        u = get(u), v = get(v);
        if ( u == v ){
            return false;
        }
        fa[v] = u;
        sz[u] += sz[v];
        return true;
    }
    bool same(int u, int v){
        return get(u) == get(v);
    }
    int size(int u){ return sz[get(u)]; }
};

int query(auto a){
    cout << a.size() << ' ';
    for ( auto &x: a ){
        cout << x + 1 << " ";
    } cout << ln;
    int c; cin >> c;
    return c;
}

void answer(auto &a){
    cout << "0 ";
    for ( auto &x: a ){
        cout << x << " ";
    } exit(0);
}

signed main(){
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);

    int n; cin >> n;
    Dsu ds(n);
    for ( int i = 0; i < n; i++ ){
        for ( int j = i + 1; j < n; j++ ){
            if ( query(vector<int>{i, j}) != 2 ){
                ds.merge(i, j);
            }
        }
    }
    vector <int> c(n);
    int ct = 0;
    for ( int i = 0; i < n; i++ ){
        if ( !c[ds.get(i)] ){
            c[ds.get(i)] = ++ct;
        } c[i] = c[ds.get(i)];
    }
    answer(c);

    cout << '\n';
}

Compilation message

carnival.cpp:59:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   59 | int query(auto a){
      |           ^~~~
carnival.cpp:68:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   68 | void answer(auto &a){
      |             ^~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 43 ms 344 KB Partially correct
2 Partially correct 59 ms 344 KB Partially correct
3 Partially correct 39 ms 344 KB Partially correct
4 Partially correct 44 ms 344 KB Partially correct
5 Partially correct 40 ms 344 KB Partially correct
6 Partially correct 39 ms 344 KB Partially correct
7 Partially correct 52 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 43 ms 344 KB Partially correct
2 Partially correct 45 ms 344 KB Partially correct
3 Partially correct 27 ms 412 KB Partially correct
4 Partially correct 57 ms 344 KB Partially correct
5 Partially correct 50 ms 344 KB Partially correct
6 Partially correct 57 ms 344 KB Partially correct
7 Partially correct 57 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 40 ms 344 KB Partially correct
2 Partially correct 57 ms 344 KB Partially correct
3 Partially correct 46 ms 344 KB Partially correct
4 Partially correct 53 ms 344 KB Partially correct
5 Partially correct 47 ms 344 KB Partially correct
6 Partially correct 58 ms 596 KB Partially correct
7 Partially correct 54 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 49 ms 344 KB Partially correct
2 Partially correct 48 ms 344 KB Partially correct
3 Partially correct 45 ms 344 KB Partially correct
4 Partially correct 64 ms 344 KB Partially correct
5 Partially correct 52 ms 344 KB Partially correct
6 Partially correct 41 ms 344 KB Partially correct
7 Partially correct 48 ms 344 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 46 ms 344 KB Partially correct
2 Partially correct 46 ms 344 KB Partially correct
3 Partially correct 48 ms 344 KB Partially correct
4 Partially correct 52 ms 344 KB Partially correct
5 Partially correct 58 ms 344 KB Partially correct
6 Partially correct 50 ms 344 KB Partially correct
7 Partially correct 45 ms 344 KB Partially correct