Submission #1073567

# Submission time Handle Problem Language Result Execution time Memory
1073567 2024-08-24T16:12:03 Z vjudge1 Simurgh (IOI17_simurgh) C++17
0 / 100
359 ms 348 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++){
        int cnt=0;
        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)){
                cnt++;
                adj[edges[i].first].push_back(edges[i].second);
                r.push_back(i);
            }
        }
        if(cnt != n-1){
            continue;
        }

        DFS(0);
        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:33: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]
   33 |         for(int i=0; i < edges.size(); i++){
      |                      ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 359 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 359 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 359 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB correct
2 Incorrect 2 ms 348 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 359 ms 348 KB WA in grader: NO
2 Halted 0 ms 0 KB -