Submission #64191162
Source Code Expand
Copy
#include <stdio.h>int N, Q;int op[312345], a[312345], b[312345];int pos_of_hato[1123456];int name_of_pos[1123456];int pos_of_name[1123456];int main(void) {int i;if (scanf("%d%d", &N, &Q) != 2) return 1;for (i = 0; i < Q; i++) {if (scanf("%d%d", &op[i], &a[i]) != 2) return 1;if (op[i] != 3) {if (scanf("%d", &b[i]) != 1) return 1;}}for (i = 1; i <= N; i++) {pos_of_hato[i] = i;name_of_pos[i] = i;
#include <stdio.h>
int N, Q;
int op[312345], a[312345], b[312345];
int pos_of_hato[1123456];
int name_of_pos[1123456];
int pos_of_name[1123456];
int main(void) {
int i;
if (scanf("%d%d", &N, &Q) != 2) return 1;
for (i = 0; i < Q; i++) {
if (scanf("%d%d", &op[i], &a[i]) != 2) return 1;
if (op[i] != 3) {
if (scanf("%d", &b[i]) != 1) return 1;
}
}
for (i = 1; i <= N; i++) {
pos_of_hato[i] = i;
name_of_pos[i] = i;
pos_of_name[i] = i;
}
for (i = 0; i < Q; i++) {
switch (op[i]) {
case 1:
pos_of_hato[a[i]] = pos_of_name[b[i]];
break;
case 2:
{
int pos1 = pos_of_name[a[i]];
int pos2 = pos_of_name[b[i]];
int temp;
temp = name_of_pos[pos1];
name_of_pos[pos1] = name_of_pos[pos2];
name_of_pos[pos2] = temp;
pos_of_name[name_of_pos[pos1]] = pos1;
pos_of_name[name_of_pos[pos2]] = pos2;
}
break;
case 3:
printf("%d\n", name_of_pos[pos_of_hato[a[i]]]);
break;
}
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Pigeon Swap |
| User | mikecat |
| Language | C (gcc 12.2.0) |
| Score | 350 |
| Code Size | 1025 Byte |
| Status | AC |
| Exec Time | 98 ms |
| Memory | 17012 KB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 1656 KB |
| 00_sample_01.txt | AC | 1 ms | 1664 KB |
| 00_sample_02.txt | AC | 1 ms | 1780 KB |
| 01_random_03.txt | AC | 85 ms | 16964 KB |
| 01_random_04.txt | AC | 86 ms | 17000 KB |
| 01_random_05.txt | AC | 85 ms | 16892 KB |
| 01_random_06.txt | AC | 88 ms | 16976 KB |
| 01_random_07.txt | AC | 7 ms | 9308 KB |
| 01_random_08.txt | AC | 49 ms | 11176 KB |
| 01_random_09.txt | AC | 55 ms | 17012 KB |
| 01_random_10.txt | AC | 62 ms | 16668 KB |
| 01_random_11.txt | AC | 74 ms | 16532 KB |
| 01_random_12.txt | AC | 53 ms | 16972 KB |
| 01_random_13.txt | AC | 87 ms | 16168 KB |
| 01_random_14.txt | AC | 66 ms | 16512 KB |
| 01_random_15.txt | AC | 51 ms | 17008 KB |
| 01_random_16.txt | AC | 96 ms | 16328 KB |
| 01_random_17.txt | AC | 86 ms | 16140 KB |
| 01_random_18.txt | AC | 60 ms | 17000 KB |
| 01_random_19.txt | AC | 70 ms | 16548 KB |
| 01_random_20.txt | AC | 63 ms | 16720 KB |
| 01_random_21.txt | AC | 58 ms | 16976 KB |
| 01_random_22.txt | AC | 88 ms | 16220 KB |
| 01_random_23.txt | AC | 91 ms | 16332 KB |
| 01_random_24.txt | AC | 79 ms | 16264 KB |
| 01_random_25.txt | AC | 98 ms | 16476 KB |
| 01_random_26.txt | AC | 92 ms | 16368 KB |
| 01_random_27.txt | AC | 97 ms | 16476 KB |
| 01_random_28.txt | AC | 77 ms | 16548 KB |
| 01_random_29.txt | AC | 96 ms | 16460 KB |
| 01_random_30.txt | AC | 39 ms | 5284 KB |