Submission #613852

# Submission time Handle Problem Language Result Execution time Memory
613852 2022-07-30T12:07:20 Z Mr_Husanboy Simurgh (IOI17_simurgh) C++14
0 / 100
7 ms 2640 KB
#include "simurgh.h"
#include<bits/stdc++.h>

using namespace std;
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define ff first
#define ss second


vector<int> g[1005];

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
    int m = u.size();
    vector<int> vis(n);
    function<void(int)> dfs = [&](int i){
        vis[i] = 1;
        for(auto u : g[i]){
            if(!vis[u]) dfs(u);
        }
    };
    for(int i = 0; i <(1<<m); i++){
        vector<int> tem;
        vis.assign(n,0);
        for(int j = 0; j < m; j++){
            if(i & (1 << j)){
                tem.push_back(j);
                g[u[j]].push_back(v[j]);
                g[v[j]].push_back(u[j]);
            }
        }
        if(tem.size() != n-1) continue;
        dfs(0);
        int cnt = 0;
        for(auto u : vis) cnt += u;
        if(tem.size() == n-1 && cnt == n){
            //cout << "H " << endl;
         //   for(auto u:tem) cout << u << ' '; cout << endl;
            if(count_common_roads(tem) == n-1) return tem;
        }
    }
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:32:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |         if(tem.size() != n-1) continue;
      |            ~~~~~~~~~~~^~~~~~
simurgh.cpp:36:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |         if(tem.size() == n-1 && cnt == n){
      |            ~~~~~~~~~~~^~~~~~
simurgh.cpp:15:22: warning: control reaches end of non-void function [-Wreturn-type]
   15 |     vector<int> vis(n);
      |                      ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB correct
2 Runtime error 7 ms 2640 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB WA in grader: NO
2 Halted 0 ms 0 KB -