Submission #66213596
Source Code Expand
Copy
#include <stdio.h>int ec[212345], es[212345][2];int main(void) {int N, M;int i;int cur, prev, count;if (scanf("%d%d", &N, &M) != 2) return 1;if (N != M) {puts("No");return 0;}for (i = 0; i < M; i++) {int A, B;if (scanf("%d%d", &A, &B) != 2) return 1;if (A == B || ec[A] >= 2 || ec[B] >= 2) {puts("No");return 0;}es[A][ec[A]++] = B;
#include <stdio.h>
int ec[212345], es[212345][2];
int main(void) {
int N, M;
int i;
int cur, prev, count;
if (scanf("%d%d", &N, &M) != 2) return 1;
if (N != M) {
puts("No");
return 0;
}
for (i = 0; i < M; i++) {
int A, B;
if (scanf("%d%d", &A, &B) != 2) return 1;
if (A == B || ec[A] >= 2 || ec[B] >= 2) {
puts("No");
return 0;
}
es[A][ec[A]++] = B;
es[B][ec[B]++] = A;
}
cur = 1;
prev = -1;
count = 1;
for (;;) {
int next = es[cur][es[cur][0] == prev];
if (next == 1) break;
prev = cur;
cur = next;
count++;
}
puts(count == N ? "Yes" : "No");
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Cycle Graph? |
| User | mikecat |
| Language | C (gcc 12.2.0) |
| Score | 300 |
| Code Size | 641 Byte |
| Status | AC |
| Exec Time | 43 ms |
| Memory | 3960 KB |
Judge Result
| Set Name | Sample | All | AfterContest | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | 0 / 0 | ||||||
| Status |
|
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt |
| AfterContest | after_contest_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| after_contest_01.txt | AC | 0 ms | 1624 KB |
| min.txt | AC | 0 ms | 1612 KB |
| random_01.txt | AC | 3 ms | 3888 KB |
| random_02.txt | AC | 1 ms | 1836 KB |
| random_03.txt | AC | 43 ms | 3960 KB |
| random_04.txt | AC | 11 ms | 2340 KB |
| random_05.txt | AC | 41 ms | 3960 KB |
| random_06.txt | AC | 1 ms | 1668 KB |
| random_07.txt | AC | 42 ms | 3832 KB |
| random_08.txt | AC | 14 ms | 2532 KB |
| random_09.txt | AC | 2 ms | 3796 KB |
| random_10.txt | AC | 2 ms | 3684 KB |
| random_11.txt | AC | 42 ms | 3944 KB |
| random_12.txt | AC | 23 ms | 3064 KB |
| random_13.txt | AC | 41 ms | 3928 KB |
| random_14.txt | AC | 2 ms | 1776 KB |
| random_15.txt | AC | 42 ms | 3864 KB |
| random_16.txt | AC | 20 ms | 2916 KB |
| random_17.txt | AC | 0 ms | 1616 KB |
| random_18.txt | AC | 0 ms | 1536 KB |
| random_19.txt | AC | 0 ms | 1632 KB |
| random_20.txt | AC | 0 ms | 1568 KB |
| random_21.txt | AC | 1 ms | 1564 KB |
| sample_01.txt | AC | 0 ms | 1616 KB |
| sample_02.txt | AC | 0 ms | 1616 KB |