이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define cps(x) sort(all(x)), (x).erase(unique(all(x)), end(x))
#define cps2(x, y) sort(all(x), y), (x).erase(unique(all(x)), end(x))
#define mem(x, y) memset(& x, y, sizeof(x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int n0 = 1003;
int n, used[n0], g2[n0][n0];
vector <int> comp;
bitset <n0> g[n0], b;
void dfs(int v) {
comp.pb(v);
used[v] = 1;
for (int to = 0; to < n; to++) {
if (!g[v][to] || used[to]) continue;
dfs(to);
}
}
int construct(vector<vector<int>> p) {
n = p.size();
int type = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (p[i][j]) g[i][j] = 1;
if (p[i][j] == 2) type = 1;
}
}
for (int i = 0; i < n; i++) {
if (!used[i]) {
comp.clear();
dfs(i);
b = g[comp[0]];
for (int j : comp)
if (b != g[j]) return 0;
if (!type) {
for (int j = 1; j < SZ(comp); j++)
g2[comp[0]][comp[j]] = 1;
} else {
if (SZ(comp) == 2) return 0;
for (int j = 0; j < SZ(comp); j++)
g2[comp[j]][comp[(j + 1) % SZ(comp)]] = 1;
}
}
}
vector<vector<int>> answer;
for (int i = 0; i < n; i++) {
vector<int> row;
row.resize(n);
for (int j = 0; j < n; j++)
if (g2[i][j] || g2[j][i]) row[j] = 1;
answer.push_back(row);
}
build(answer);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |