Submission #566584

# Submission time Handle Problem Language Result Execution time Memory
566584 2022-05-22T12:37:59 Z lorenzoferrari Simurgh (IOI17_simurgh) C++17
0 / 100
565 ms 1048576 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;

int count_common_roads(const vector<int>& r);

int qq = 0;
int ask(vector<int>& r) {
  assert(++qq <= 30000);
  return count_common_roads(r);
}

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
  int m = u.size();
  // vector<vector<int>> adj(n);
  // for (int i = 0; i < m; ++i) {
  //   adj[u[i]].push_back(v[i]);
  //   adj[v[i]].push_back(u[i]);
  // }
  vector<int> p(n);
  auto find = [&](auto&& self, int i) -> int {
    return p[i] == i ? i : p[i] = self(self, p[i]);
  };
  auto onion = [&](int a, int b) -> bool {
    a = find(find,a);
    b = find(find,b);
    if (a == b) return false;
    p[a] = b;
    return true;
  };
  vector<int> ans;
  vector<int> st;
  auto cycle = [&]() -> bool {
    for (int i = 0; i < n; ++i) p[i] = n;
    for (int i : st) {
      if (!onion(u[i], v[i])) {
        return true;
      }
    }
    return false;
  };
  auto generate = [&](auto&& self, int i) -> void {
    if (cycle()) return;
    if (int(st.size()) == n-1) {
      if (ask(st) == n-1) ans = st;
      return;
    }
    if (i == m) return;
    st.push_back(i);
    self(self, i+1);
    st.pop_back();
    self(self, i+1);
  };
  generate(generate, 0);
  return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 565 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 565 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 565 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 563 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 565 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -