Submission #426819

# Submission time Handle Problem Language Result Execution time Memory
426819 2021-06-14T10:09:14 Z Hazem Simurgh (IOI17_simurgh) C++14
13 / 100
3000 ms 332 KB
#include "simurgh.h"
#include <bits/stdc++.h>

using namespace std;

int n,m,cnt;
int vis[10];
vector<int>vec,adj[10],ans,U,V;

void dfs(int i){

	if(vis[i])
		return ;
	vis[i] = 1;
	for(auto x:adj[i])
		dfs(x);
}

bool check(){

	for(int i=0;i<n;i++)
		vis[i] = 0,adj[i].clear();
	
	for(auto x:vec){
		adj[U[x]].push_back(V[x]);	
		adj[V[x]].push_back(U[x]);
	}
	dfs(0);
	bool ret = 1;
	for(int i=0;i<n;i++)
		ret &= vis[i];
	
	return ret;
}

void bt(int idx){

	if(vec.size()==n-1){
		if(!check())		
			return ;
		cnt++;
		if(count_common_roads(vec)==n-1)
			ans = vec;
		return ;
	}

	if(idx==m)
		return;

	bt(idx+1);
	vec.push_back(idx);
	bt(idx+1);
	vec.pop_back();
}

std::vector<int> find_roads(int n1, std::vector<int> u, std::vector<int> v) {
	
	n = n1;m = u.size();
	U = u,V = v;
	bt(0);

	assert(cnt<=25000);
	return ans;
}

Compilation message

simurgh.cpp: In function 'void bt(int)':
simurgh.cpp:38:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |  if(vec.size()==n-1){
      |     ~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 288 KB correct
2 Correct 14 ms 288 KB correct
3 Correct 14 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 3 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 2 ms 204 KB correct
13 Correct 15 ms 204 KB correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 288 KB correct
2 Correct 14 ms 288 KB correct
3 Correct 14 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 3 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 2 ms 204 KB correct
13 Correct 15 ms 204 KB correct
14 Execution timed out 3060 ms 332 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 288 KB correct
2 Correct 14 ms 288 KB correct
3 Correct 14 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 3 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 2 ms 204 KB correct
13 Correct 15 ms 204 KB correct
14 Execution timed out 3060 ms 332 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB correct
2 Incorrect 38 ms 204 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 288 KB correct
2 Correct 14 ms 288 KB correct
3 Correct 14 ms 204 KB correct
4 Correct 1 ms 204 KB correct
5 Correct 1 ms 204 KB correct
6 Correct 3 ms 204 KB correct
7 Correct 1 ms 204 KB correct
8 Correct 1 ms 204 KB correct
9 Correct 1 ms 204 KB correct
10 Correct 1 ms 204 KB correct
11 Correct 1 ms 204 KB correct
12 Correct 2 ms 204 KB correct
13 Correct 15 ms 204 KB correct
14 Execution timed out 3060 ms 332 KB Time limit exceeded
15 Halted 0 ms 0 KB -