# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
786284 | vjudge1 | 수천개의 섬 (IOI22_islands) | C++17 | 25 ms | 5428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "islands.h"
#include <bits/stdc++.h>
using namespace std;
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
if (N == 2) {
vector<int> f0, f1;
for (int i = 0; i < M; i++) {
(U[i] == 0 ? f0 : f1).push_back(i);
}
if (f0.size() < 2 || f1.size() < 1) {
return false;
}
return vector{f0[0], f1[0], f0[1], f0[0], f1[0], f0[1]};
}
bool S3 = M % 2 == 0;
vector<vector<pair<int, int>>> adj(N);
for (int i = 1; i < M; i += 2) {
if (U[i - 1] != V[i] || V[i - 1] != U[i]) {
S3 = 0;
}
adj[U[i]].emplace_back(V[i], i);
adj[V[i]].emplace_back(U[i], i - 1);
}
if (S3) {
int x = 0, y = -1;
vector<int> p;
while (1) {
if (adj[x].size() < 2 - (y == -1)) {
return false;
}
if (adj[x].size() > 2 - (y == -1)) {
auto ans = p;
int u, v;
if (y == -1) {
u = adj[x][0].second;
v = adj[x][1].second;
} else {
u = adj[x][adj[x][0].second == (y ^ 1) ? 1 : 0].second;
v = adj[x][adj[x][2].second == (y ^ 1) ? 1 : 2].second;
}
ans.push_back(u);
ans.push_back(u ^ 1);
ans.push_back(v);
ans.push_back(v ^ 1);
ans.push_back(u ^ 1);
ans.push_back(u);
ans.push_back(v ^ 1);
ans.push_back(v);
for (int i = p.size() - 1; i >= 0; i--) {
ans.push_back(p[i]);
}
return ans;
}
if (adj[x][0].second == (y ^ 1)) {
tie(x, y) = adj[x][1];
} else {
tie(x, y) = adj[x][0];
}
p.push_back(y);
}
}
int a, b, c, d;
for (int i = 0; i < M; i++) {
if (U[i] == 0) {
if (V[i] == 1) {
a = i;
}
if (V[i] == 2) {
c = i;
}
}
if (V[i] == 0) {
if (U[i] == 1) {
b = i;
}
if (U[i] == 2) {
d = i;
}
}
}
return vector{a, b, c, d, b, a, d, c};
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |