답안 #300217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300217 2020-09-17T01:38:02 Z madlogic 슈퍼트리 잇기 (IOI20_supertrees) C++17
0 / 100
1 ms 256 KB
#include "supertrees.h"
#include <bits/stdc++.h>

using namespace std;

int construct(std::vector<std::vector<int>> p) {
  int n = p.size();
  vector<vector<int>> adj(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) if (p[i][j]) {
      adj[i].push_back(j);
      adj[j].push_back(i);
    }
  }
  vector<int> cc;
  vector<bool> vis(n);
  function<void(int)> dfs = [&](int u) {
    vis[u] = true;
    cc.push_back(u);
    for (int to : adj[u]) if (!vis[to]) {
      dfs(to);
    }
  };
  vector<vector<int>> answer(n, vector<int>(n));
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i);
      int m = cc.size();
      int edges = 0;
      for (int p : cc)
        edges += adj[p].size();
      edges /= 2;
      if (edges >= m) 
        return 0;
      for (int j = 0; j < m - 1; j++)
        answer[cc[j]][cc[j + 1]] = answer[cc[j + 1]][cc[j]] = 1;
      cc.clear();
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (p[i][j] == 0 && answer[i][j])
        return 0;
  build(answer);
  return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Answer gives possible 0 while actual possible 1
2 Halted 0 ms 0 KB -