답안 #1073587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1073587 2024-08-24T16:21:47 Z vjudge1 Simurgh (IOI17_simurgh) C++17
13 / 100
325 ms 592 KB
#include "simurgh.h"
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>>adj(505);
vector<bool> vis(505,0);

void DFS(int n){
    vis[n] = 1;

    for(auto x: adj[n]){
        if(vis[x])continue;
        DFS(x);
    }
}

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
	vector<pair<int,int>> edges;
	for(int i=0; i < u.size(); i++){
        edges.push_back({u[i],v[i]});
	}

	for(int b=0; b < (1<<edges.size()); b++){
        vector<int> r;

        for(int i=0; i < n; i++){
            adj[i].clear();
            vis[i] = 0;
        }

        for(int i=0; i < edges.size(); i++){
            if(b & (1<<i)){
                adj[edges[i].first].push_back(edges[i].second);
                adj[edges[i].second].push_back(edges[i].first);
                r.push_back(i);
            }
        }
        if(r.size() != n-1){
            continue;
        }

        DFS(0);
        int cnt = 0;
        for(int i=0; i < n; i++){
            if(vis[i]){
                cnt++;
            }else{
                break;
            }
        }

        int aux;
        if(cnt == n){
            aux = count_common_roads(r);
        }else{
            continue;
        }

        if(aux == n-1){
            return r;
        }
	}

	return {0};
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=0; i < u.size(); i++){
      |               ~~^~~~~~~~~~
simurgh.cpp:32:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int i=0; i < edges.size(); i++){
      |                      ~~^~~~~~~~~~~~~~
simurgh.cpp:39:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if(r.size() != n-1){
      |            ~~~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB correct
2 Correct 258 ms 348 KB correct
3 Correct 325 ms 592 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 1 ms 348 KB correct
6 Correct 6 ms 448 KB correct
7 Correct 0 ms 344 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 3 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 4 ms 348 KB correct
13 Correct 116 ms 348 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB correct
2 Correct 258 ms 348 KB correct
3 Correct 325 ms 592 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 1 ms 348 KB correct
6 Correct 6 ms 448 KB correct
7 Correct 0 ms 344 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 3 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 4 ms 348 KB correct
13 Correct 116 ms 348 KB correct
14 Incorrect 2 ms 348 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB correct
2 Correct 258 ms 348 KB correct
3 Correct 325 ms 592 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 1 ms 348 KB correct
6 Correct 6 ms 448 KB correct
7 Correct 0 ms 344 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 3 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 4 ms 348 KB correct
13 Correct 116 ms 348 KB correct
14 Incorrect 2 ms 348 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB correct
2 Incorrect 2 ms 348 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 344 KB correct
2 Correct 258 ms 348 KB correct
3 Correct 325 ms 592 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 1 ms 348 KB correct
6 Correct 6 ms 448 KB correct
7 Correct 0 ms 344 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 3 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 4 ms 348 KB correct
13 Correct 116 ms 348 KB correct
14 Incorrect 2 ms 348 KB WA in grader: NO
15 Halted 0 ms 0 KB -