Submission #83747

# Submission time Handle Problem Language Result Execution time Memory
83747 2018-11-10T10:05:04 Z WLZ Simurgh (IOI17_simurgh) C++17
13 / 100
3000 ms 776 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);
        cc++;
      }
    }
    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 Correct 57 ms 256 KB correct
2 Correct 20 ms 372 KB correct
3 Correct 40 ms 412 KB correct
4 Correct 3 ms 460 KB correct
5 Correct 2 ms 596 KB correct
6 Correct 4 ms 624 KB correct
7 Correct 2 ms 624 KB correct
8 Correct 2 ms 648 KB correct
9 Correct 2 ms 648 KB correct
10 Correct 4 ms 648 KB correct
11 Correct 2 ms 648 KB correct
12 Correct 3 ms 648 KB correct
13 Correct 40 ms 716 KB correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 256 KB correct
2 Correct 20 ms 372 KB correct
3 Correct 40 ms 412 KB correct
4 Correct 3 ms 460 KB correct
5 Correct 2 ms 596 KB correct
6 Correct 4 ms 624 KB correct
7 Correct 2 ms 624 KB correct
8 Correct 2 ms 648 KB correct
9 Correct 2 ms 648 KB correct
10 Correct 4 ms 648 KB correct
11 Correct 2 ms 648 KB correct
12 Correct 3 ms 648 KB correct
13 Correct 40 ms 716 KB correct
14 Execution timed out 3040 ms 764 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 256 KB correct
2 Correct 20 ms 372 KB correct
3 Correct 40 ms 412 KB correct
4 Correct 3 ms 460 KB correct
5 Correct 2 ms 596 KB correct
6 Correct 4 ms 624 KB correct
7 Correct 2 ms 624 KB correct
8 Correct 2 ms 648 KB correct
9 Correct 2 ms 648 KB correct
10 Correct 4 ms 648 KB correct
11 Correct 2 ms 648 KB correct
12 Correct 3 ms 648 KB correct
13 Correct 40 ms 716 KB correct
14 Execution timed out 3040 ms 764 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 764 KB correct
2 Incorrect 369 ms 776 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 256 KB correct
2 Correct 20 ms 372 KB correct
3 Correct 40 ms 412 KB correct
4 Correct 3 ms 460 KB correct
5 Correct 2 ms 596 KB correct
6 Correct 4 ms 624 KB correct
7 Correct 2 ms 624 KB correct
8 Correct 2 ms 648 KB correct
9 Correct 2 ms 648 KB correct
10 Correct 4 ms 648 KB correct
11 Correct 2 ms 648 KB correct
12 Correct 3 ms 648 KB correct
13 Correct 40 ms 716 KB correct
14 Execution timed out 3040 ms 764 KB Time limit exceeded
15 Halted 0 ms 0 KB -