Submission #83746

# Submission time Handle Problem Language Result Execution time Memory
83746 2018-11-10T10:04:10 Z WLZ Simurgh (IOI17_simurgh) C++17
0 / 100
2 ms 488 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> was;

void dfs(int u, const vector< vector<int> >& g) {
  was[u] = 1;
  for (auto& v : g[u]) {
    if (!was[v]) {
      dfs(v, g);
    }
  }
}

std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v) {
  int m = (int) u.size();
  vector<int> perm(m, 0);
  for (int i = 0; i < n - 1; i++) {  
    perm[i] = 1;
  }
  do {
    vector<int> q;
    vector< vector<int> > g(n);
    was.assign(n, 0);
    for (int i = 0; i < m; i++) {
      if (perm[i]) {
        q.push_back(i);
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
      }
    }
    int cc = 0;
    for (int i = 0; i < n; i++) {
      if (!was[i]) {
        dfs(i, g);
      }
    }
    if (cc > 1) {
      continue;
    }
    int res = count_common_roads(q);
    if (res == n - 1) {
      return q;
    }
  } while (prev_permutation(perm.begin(), perm.end()));
  return {};
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: NO
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB correct
2 Incorrect 2 ms 488 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB WA in grader: NO
2 Halted 0 ms 0 KB -