답안 #992464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
992464 2024-06-04T13:45:32 Z MuntherCarrot Simurgh (IOI17_simurgh) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;

#define ll long long
#define all(x) x.begin(), x.end()

struct dsu{
    vector<int> p, sz;
    dsu(int n){
        p.resize(n);
        iota(all(p), 0);
        sz.resize(n, 1);
    }
    int find(int x){
        return x == p[x] ? x : p[x] = find(p[x]);
    }
    void merge(int a, int b){
        a = find(a);
        b = find(b);
        p[b] = a;
        sz[a] += sz[b];
    }
    int size(){
        return *max_element(all(sz));
    }
};

int count_common_roads(const std::vector<int>& r){
    for(int i : r) cout << i << ' ';
    cout << endl;
    int x; cin >> x; return x;
}

vector<int> find_roads(int n, vector<int> u, vector<int> v){
    string prm = string(u.size() - n + 1, '0') + string(n - 1, '1');
    do{
        vector<int> vec;
        dsu A(n);
        for(int i = 0; i < u.size(); i++){
            if(prm[i] == '1'){
                vec.push_back(i);
                A.merge(u[i], v[i]);
            }
        }
        if(A.size() != n) continue;
        if(count_common_roads(vec) == n - 1){
            return vec;
        }
    }while(next_permutation(all(prm)));
    return {};
}

// int main(){
//     ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
//     find_roads(4, {0, 0, 0, 1, 1, 2}, {1, 2, 3, 2, 3, 3});
//     return 0;
// }

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i = 0; i < u.size(); i++){
      |                        ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccCLI2AT.o: in function `count_common_roads(std::vector<int, std::allocator<int> > const&)':
grader.cpp:(.text+0x370): multiple definition of `count_common_roads(std::vector<int, std::allocator<int> > const&)'; /tmp/ccXV5UBS.o:simurgh.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status