답안 #426981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426981 2021-06-14T11:33:39 Z Rouge_Hugo Simurgh (IOI17_simurgh) C++14
0 / 100
857 ms 1048580 KB
#include<bits/stdc++.h>
#include "simurgh.h"
#define fi first
#define se second
#define pb push_back
using namespace std;
int n,m;int r=0;
const int N=10;
int vis[N],yes[N];
vector<pair<int,int>>ev[N];
vector<vector<int>>ans;
vector<int>vv;
void dfs(int x)
{
    if(vis[x])return;
    r++;vis[x]=1;
    for(auto it:ev[x])
    {
        if(!yes[it.se])continue;
        dfs(it.fi);
    }
}
int ch()
{
    memset(vis,0,sizeof vis);
    for(auto it:vv)
    {
        yes[it]=1;
    }r=0;
    dfs(0);
    if(r==n)
    {
        return 1;
    }
    return 0;
}
void go(int x)
{
    if(vv.size()>n-1)return;
    if(x==m)
    {
        if(!ch())return;
        ans.pb(vv);
        return;
    }
    vv.pb(x);
    go(x+1);
    vv.pop_back();
    go(x+1);

}
vector<int> find_roads(int N,vector<int> U, vector<int> V) {
	n=N;m=U.size();
	for(int i=0;i<m;i++)
    {
        ev[U[i]].pb({V[i],i});
        ev[V[i]].pb({U[i],i});
    }
	go(0);
	for(auto it:ans)
    {
        if(count_common_roads(it)==n-1)return it;
    }
}

Compilation message

simurgh.cpp: In function 'void go(int)':
simurgh.cpp:39:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     if(vv.size()>n-1)return;
      |        ~~~~~~~~~^~~~
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1544 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1544 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1544 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB correct
2 Runtime error 857 ms 1048580 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 1544 KB WA in grader: NO
2 Halted 0 ms 0 KB -