Submission #38460460
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int n, x[200005], y[200005];
int check(int *z) {
bool g = 0;
for (int i = 0; i < n; i++)
if (z[i] % 2 == 1) {
if (i != 0 && z[i - 1] % 2 == 1) {
g = 0;
break;
}
if (i > 1 && z[i - 2] % 2 == 1) {
g = 0;
break;
}
g = 1;
}
if (!g) {
int cnt = 0;
for (int i = 0; i < n; i++)
if (z[i] % 2 == 0)
cnt++;
if (cnt >= 3)
return 3;
if (cnt != 0)
return 2;
}
return 1;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", x + i);
for (int i = 0; i < n; i++)
scanf("%d", y + i);
if (multiset<int>(x, x + n) != multiset<int>(y, y + n)) {
puts("No");
return 0;
}
int tmp = min(check(x), check(y));
// printf("tmp=%d\n", tmp);
if (tmp == 3) {
puts("Yes");
return 0;
}
if (tmp == 2) {
vector<int> va, vb;
for (int i = 0; i < n; i++)
if (x[i] % 2 == 0)
va.push_back(x[i]);
for (int i = 0; i < n; i++)
if (y[i] % 2 == 0)
vb.push_back(y[i]);
puts(va == vb ? "Yes" : "No");
return 0;
}
for (int i = 0, la = 0; i <= n; i++)
if (i == n || x[i] % 2 == 1) {
if (i - la >= 3)
sort(x + la, x + i);
la = i + 1;
}
for (int i = 0, la = 0; i <= n; i++)
if (i == n || y[i] % 2 == 1) {
if (i - la >= 3)
sort(y + la, y + i);
la = i + 1;
}
puts(vector<int>(x, x + n) == vector<int>(y, y + n) ? "Yes" : "No");
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Even Sum Triplet |
| User | nhho |
| Language | C++ (GCC 9.2.1) |
| Score | 700 |
| Code Size | 1458 Byte |
| Status | AC |
| Exec Time | 276 ms |
| Memory | 23876 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:35:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
35 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
./Main.cpp:37:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
37 | scanf("%d", x + i);
| ~~~~~^~~~~~~~~~~~~
./Main.cpp:39:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
39 | scanf("%d", y + i);
| ~~~~~^~~~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 700 / 700 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_rand_01.txt, 01_rand_02.txt, 01_rand_03.txt, 01_rand_04.txt, 01_rand_05.txt, 01_rand_06.txt, 01_rand_07.txt, 01_rand_08.txt, 01_rand_09.txt, 01_rand_10.txt, 01_rand_11.txt, 01_rand_12.txt, 01_rand_13.txt, 01_rand_14.txt, 01_rand_15.txt, 01_rand_16.txt, 02_max_rand_01.txt, 02_max_rand_02.txt, 02_max_rand_03.txt, 02_max_rand_04.txt, 02_max_rand_05.txt, 02_max_rand_06.txt, 02_max_rand_07.txt, 02_max_rand_08.txt, 03_two_even_01.txt, 03_two_even_02.txt, 03_two_even_03.txt, 03_two_even_04.txt, 03_two_even_05.txt, 03_two_even_06.txt, 03_two_even_07.txt, 03_two_even_08.txt, 03_two_even_09.txt, 03_two_even_10.txt, 03_two_even_11.txt, 03_two_even_12.txt, 03_two_even_13.txt, 03_two_even_14.txt, 03_two_even_15.txt, 03_two_even_16.txt, 04_other_01.txt, 04_other_02.txt, 04_other_03.txt, 04_other_04.txt, 04_other_05.txt, 04_other_06.txt, 04_other_07.txt, 04_other_08.txt, 04_other_09.txt, 04_other_10.txt, 04_other_11.txt, 04_other_12.txt, 04_other_13.txt, 04_other_14.txt, 04_other_15.txt, 04_other_16.txt, 05_test_01.txt, 05_test_02.txt, 05_test_03.txt, 05_test_04.txt, 05_test_05.txt, 05_test_06.txt, 05_test_07.txt, 05_test_08.txt, 05_test_09.txt, 05_test_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 8 ms | 3632 KiB |
| 00_sample_02.txt | AC | 2 ms | 3536 KiB |
| 00_sample_03.txt | AC | 3 ms | 3556 KiB |
| 01_rand_01.txt | AC | 178 ms | 18464 KiB |
| 01_rand_02.txt | AC | 243 ms | 21972 KiB |
| 01_rand_03.txt | AC | 163 ms | 17268 KiB |
| 01_rand_04.txt | AC | 215 ms | 20848 KiB |
| 01_rand_05.txt | AC | 74 ms | 15472 KiB |
| 01_rand_06.txt | AC | 96 ms | 20420 KiB |
| 01_rand_07.txt | AC | 156 ms | 19368 KiB |
| 01_rand_08.txt | AC | 100 ms | 15528 KiB |
| 01_rand_09.txt | AC | 255 ms | 22220 KiB |
| 01_rand_10.txt | AC | 122 ms | 15252 KiB |
| 01_rand_11.txt | AC | 147 ms | 16040 KiB |
| 01_rand_12.txt | AC | 159 ms | 17244 KiB |
| 01_rand_13.txt | AC | 94 ms | 18808 KiB |
| 01_rand_14.txt | AC | 69 ms | 15812 KiB |
| 01_rand_15.txt | AC | 203 ms | 22924 KiB |
| 01_rand_16.txt | AC | 172 ms | 22148 KiB |
| 02_max_rand_01.txt | AC | 237 ms | 22068 KiB |
| 02_max_rand_02.txt | AC | 191 ms | 20344 KiB |
| 02_max_rand_03.txt | AC | 111 ms | 22008 KiB |
| 02_max_rand_04.txt | AC | 76 ms | 16600 KiB |
| 02_max_rand_05.txt | AC | 125 ms | 14788 KiB |
| 02_max_rand_06.txt | AC | 166 ms | 18196 KiB |
| 02_max_rand_07.txt | AC | 74 ms | 15748 KiB |
| 02_max_rand_08.txt | AC | 107 ms | 22516 KiB |
| 03_two_even_01.txt | AC | 273 ms | 23664 KiB |
| 03_two_even_02.txt | AC | 168 ms | 18028 KiB |
| 03_two_even_03.txt | AC | 135 ms | 15844 KiB |
| 03_two_even_04.txt | AC | 180 ms | 18556 KiB |
| 03_two_even_05.txt | AC | 89 ms | 19096 KiB |
| 03_two_even_06.txt | AC | 74 ms | 17120 KiB |
| 03_two_even_07.txt | AC | 181 ms | 22144 KiB |
| 03_two_even_08.txt | AC | 178 ms | 22096 KiB |
| 03_two_even_09.txt | AC | 190 ms | 19100 KiB |
| 03_two_even_10.txt | AC | 250 ms | 22948 KiB |
| 03_two_even_11.txt | AC | 142 ms | 16084 KiB |
| 03_two_even_12.txt | AC | 191 ms | 19320 KiB |
| 03_two_even_13.txt | AC | 68 ms | 14448 KiB |
| 03_two_even_14.txt | AC | 88 ms | 17212 KiB |
| 03_two_even_15.txt | AC | 105 ms | 14908 KiB |
| 03_two_even_16.txt | AC | 113 ms | 16144 KiB |
| 04_other_01.txt | AC | 231 ms | 20804 KiB |
| 04_other_02.txt | AC | 143 ms | 15468 KiB |
| 04_other_03.txt | AC | 160 ms | 16880 KiB |
| 04_other_04.txt | AC | 224 ms | 20560 KiB |
| 04_other_05.txt | AC | 64 ms | 13880 KiB |
| 04_other_06.txt | AC | 77 ms | 16152 KiB |
| 04_other_07.txt | AC | 196 ms | 23100 KiB |
| 04_other_08.txt | AC | 120 ms | 16652 KiB |
| 04_other_09.txt | AC | 239 ms | 22432 KiB |
| 04_other_10.txt | AC | 134 ms | 16124 KiB |
| 04_other_11.txt | AC | 236 ms | 22172 KiB |
| 04_other_12.txt | AC | 180 ms | 19832 KiB |
| 04_other_13.txt | AC | 75 ms | 15464 KiB |
| 04_other_14.txt | AC | 118 ms | 23760 KiB |
| 04_other_15.txt | AC | 121 ms | 16588 KiB |
| 04_other_16.txt | AC | 162 ms | 21060 KiB |
| 05_test_01.txt | AC | 3 ms | 3572 KiB |
| 05_test_02.txt | AC | 3 ms | 3572 KiB |
| 05_test_03.txt | AC | 3 ms | 3536 KiB |
| 05_test_04.txt | AC | 184 ms | 23876 KiB |
| 05_test_05.txt | AC | 276 ms | 23824 KiB |
| 05_test_06.txt | AC | 266 ms | 23780 KiB |
| 05_test_07.txt | AC | 250 ms | 23700 KiB |
| 05_test_08.txt | AC | 252 ms | 23872 KiB |
| 05_test_09.txt | AC | 268 ms | 23376 KiB |
| 05_test_10.txt | AC | 274 ms | 23480 KiB |