# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
460986 | kingfran1907 | Potemkin cycle (CEOI15_indcyc) | C++14 | 390 ms | 5184 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long llint;
const int maxn = 1010;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 18;
const int off = 1 << logo;
const int treesiz = off << 1;
int n, m;
vector< int > graph[maxn];
int eg[maxn][maxn];
int dis[maxn];
queue< int > q;
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d%d", &a, &b);
graph[a].push_back(b);
graph[b].push_back(a);
eg[a][b] = eg[b][a] = 1;
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < graph[i].size(); j++) {
for (int k = j + 1; k < graph[i].size(); k++) {
int x = graph[i][j];
int y = graph[i][k];
if (eg[x][y]) continue;
for (int i = 1; i <= n; i++) dis[i] = inf;
dis[i] = -1;
for (int tren : graph[i]) dis[tren] = -1;
dis[y] = inf; dis[x] = 0;
q.push(x);
while (!q.empty()) {
int x = q.front();
q.pop();
for (int tren : graph[x]) {
if (dis[tren] == inf) {
dis[tren] = 1 + dis[x];
q.push(tren);
}
}
}
if (dis[y] == inf) continue;
vector< int > v;
int ptr = y;
while (ptr != x) {
v.push_back(ptr);
for (int tren : graph[ptr]) {
if (dis[tren] + 1 == dis[ptr]) {
ptr = tren;
break;
}
}
}
printf("%d %d ", i, x);
for (int i = 0; i < v.size(); i++)
printf("%d ", v[i]);
printf("\n");
return 0;
}
}
}
printf("no\n");
return 0;
}
컴파일 시 표준 에러 (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... |
# | 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... |