Submission #992457

# Submission time Handle Problem Language Result Execution time Memory
992457 2024-06-04T13:34:16 Z MuntherCarrot Simurgh (IOI17_simurgh) C++14
0 / 100
1 ms 612 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);

vector<int> find_roads(int n, vector<int> u, vector<int> v){
    for(int msk = 0; msk < (1 << n); msk++){
        vector<int> vec;
        dsu A(n);
        for(int i = 0; i < n; i++){
            if((msk >> 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;
        }
    }
}

// int main(){
//     ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
//     vector<int> vec = {-2, 2, 2, -2, -2, 2};
//     cout << count_swaps(vec) << endl;
//     return 0;
// }

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 612 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 612 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 612 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB correct
2 Incorrect 0 ms 348 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 612 KB WA in grader: NO
2 Halted 0 ms 0 KB -