답안 #770494

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
770494 2023-07-01T10:47:24 Z Ahmed57 사육제 (CEOI14_carnival) C++17
0 / 100
1 ms 316 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
//DSU
int mn = 10001;
int pr[151];

int findleader(int x){
    if(pr[x]==x){
        return x;
    }
    return pr[x] = findleader(pr[x]);
}
bool samegroup(int x,int y){
    int led1 = findleader(x);
    int led2 = findleader(y);
    return led1==led2;
}
void mergegroup(int x,int y){
    int led1 = findleader(x);
    int led2 = findleader(y);
    if(led1==led2)return;
    pr[led2] = led1;
}
int query(vector<int> x){
    cout<<x.size()<<" ";
    for(auto i:x){
        cout<<i+1<<" ";
    }
    cout<<endl;
    int lol;cin>>lol;return lol;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i = 0;i<n;i++)pr[i] = i;
    int b = 13;
    int vis[n] = {0};
    for(int i = 0;i<n;i++){
        if(vis[findleader(i)])continue;
        for(int j = i-(i%b);j<n;j++){
            if(j%b==0){
                vector<int> lol = {i};
                for(int e = j;e<min(n,j+b);e++){
                    if(e!=i){
                        lol.push_back(e);cout<<e<<endl;
                    }
                }
                if(query(lol)==lol.size())continue;
                for(int e = j;e<min(n,j+b);e++){
                    if(e!=i){
                        if(query({i,e})==1){
                            mergegroup(i,e);
                        }
                    }
                }
            }
        }
        vis[i] = 1;
    }
    int vis2[n] = {0};
    int z = 0;
    cout<<"0 ";
    for(int i = 0;i<n;i++){
        if(!vis2[findleader(i)]){
            vis2[findleader(i)] = ++z;
        }
        cout<<vis2[findleader(i)]<<" ";
    }
    return 0;
}

Compilation message

carnival.cpp: In function 'int main()':
carnival.cpp:51:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                 if(query(lol)==lol.size())continue;
      |                    ~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 316 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -