# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
547429 | 2022-04-10T16:47:36 Z | Olympia | Genetics (BOI18_genetics) | C++17 | 1589 ms | 36888 KB |
#include <cmath> #include <iostream> #include <set> #include <climits> #include <algorithm> #include <cassert> #include <vector> #include <iomanip> #include <type_traits> #include <string> #include <queue> #include <map> #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M, K; cin >> N >> M >> K; vector<pair<string,int>> arr(N); for (int i = 0; i < N; i++) { cin >> arr[i].first; arr[i].second = i; } random_shuffle(arr.begin(), arr.end()); vector<pair<int,int>> blocks; int sq = 400; for (int i = 0; i < N/sq; i++) { blocks.push_back({i * sq, i * sq + sq - 1}); } if (blocks.empty()) blocks.push_back({0, N - 1}); else blocks.back().second = N - 1; int id[N]; int myMap[256]; myMap['A'] = 0, myMap['C'] = 1, myMap['G'] = 2, myMap['T'] = 3; int oc[blocks.size()][M][4]; for (int i = 0; i < blocks.size(); i++) { for (int j = 0; j < M; j++) { for (int k = 0; k < 4; k++) { oc[i][j][k] = 0; } } } for (int i = 0; i < blocks.size(); i++) { for (int j = blocks[i].first; j <= blocks[i].second; j++) { id[j] = i; for (int k = 0; k < M; k++) { oc[i][k][myMap[arr[j].first[k]]]++; } } } vector<bool> pos(N); for (int i = 0; i < N; i++) { pos[i] = true; } for (int i = 0; i < N; i++) { for (int index = 0; index < blocks.size(); index++) { int tot = 0; for (int j = 0; j < M; j++) { for (int k = 0; k < 4; k++) { if (k != myMap[arr[i].first[j]]) { tot += oc[index][j][k]; } } } if (tot != (blocks[index].second - blocks[index].first + 1 - (index == id[i])) * K) { pos[i] = false; break; } } } for (int j = 0; j < pos.size(); j++) { if (!pos[j]) continue; bool fine = true; for (int i = 0; i < N; i++) { if (i == j) continue; int cntr = 0; for (int k = 0; k < M; k++) { cntr += (arr[j].first[k]!= arr[i].first[k]); } if (cntr != K) { fine = false; break; } } if (fine) { cout << arr[j].second + 1; exit(0); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 324 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 3412 KB | Output is correct |
2 | Correct | 114 ms | 4180 KB | Output is correct |
3 | Correct | 117 ms | 4008 KB | Output is correct |
4 | Correct | 18 ms | 1356 KB | Output is correct |
5 | Correct | 113 ms | 4180 KB | Output is correct |
6 | Correct | 117 ms | 4168 KB | Output is correct |
7 | Correct | 28 ms | 2020 KB | Output is correct |
8 | Correct | 24 ms | 2012 KB | Output is correct |
9 | Correct | 109 ms | 3884 KB | Output is correct |
10 | Correct | 79 ms | 3880 KB | Output is correct |
11 | Correct | 79 ms | 3456 KB | Output is correct |
12 | Correct | 66 ms | 3468 KB | Output is correct |
13 | Correct | 100 ms | 3456 KB | Output is correct |
14 | Correct | 259 ms | 3056 KB | Output is correct |
15 | Correct | 57 ms | 3088 KB | Output is correct |
16 | Correct | 91 ms | 3012 KB | Output is correct |
17 | Correct | 57 ms | 4016 KB | Output is correct |
18 | Correct | 125 ms | 3996 KB | Output is correct |
19 | Correct | 130 ms | 4024 KB | Output is correct |
20 | Correct | 129 ms | 3976 KB | Output is correct |
21 | Correct | 88 ms | 3940 KB | Output is correct |
22 | Correct | 94 ms | 3968 KB | Output is correct |
23 | Correct | 116 ms | 4004 KB | Output is correct |
24 | Correct | 165 ms | 4004 KB | Output is correct |
25 | Correct | 124 ms | 3960 KB | Output is correct |
26 | Correct | 152 ms | 3924 KB | Output is correct |
27 | Correct | 119 ms | 3988 KB | Output is correct |
28 | Correct | 141 ms | 3980 KB | Output is correct |
29 | Correct | 144 ms | 4000 KB | Output is correct |
30 | Correct | 58 ms | 4072 KB | Output is correct |
31 | Correct | 62 ms | 4132 KB | Output is correct |
32 | Correct | 63 ms | 4172 KB | Output is correct |
33 | Correct | 1 ms | 316 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 3412 KB | Output is correct |
2 | Correct | 114 ms | 4180 KB | Output is correct |
3 | Correct | 117 ms | 4008 KB | Output is correct |
4 | Correct | 18 ms | 1356 KB | Output is correct |
5 | Correct | 113 ms | 4180 KB | Output is correct |
6 | Correct | 117 ms | 4168 KB | Output is correct |
7 | Correct | 28 ms | 2020 KB | Output is correct |
8 | Correct | 24 ms | 2012 KB | Output is correct |
9 | Correct | 109 ms | 3884 KB | Output is correct |
10 | Correct | 79 ms | 3880 KB | Output is correct |
11 | Correct | 79 ms | 3456 KB | Output is correct |
12 | Correct | 66 ms | 3468 KB | Output is correct |
13 | Correct | 100 ms | 3456 KB | Output is correct |
14 | Correct | 259 ms | 3056 KB | Output is correct |
15 | Correct | 57 ms | 3088 KB | Output is correct |
16 | Correct | 91 ms | 3012 KB | Output is correct |
17 | Correct | 57 ms | 4016 KB | Output is correct |
18 | Correct | 125 ms | 3996 KB | Output is correct |
19 | Correct | 130 ms | 4024 KB | Output is correct |
20 | Correct | 129 ms | 3976 KB | Output is correct |
21 | Correct | 88 ms | 3940 KB | Output is correct |
22 | Correct | 94 ms | 3968 KB | Output is correct |
23 | Correct | 116 ms | 4004 KB | Output is correct |
24 | Correct | 165 ms | 4004 KB | Output is correct |
25 | Correct | 124 ms | 3960 KB | Output is correct |
26 | Correct | 152 ms | 3924 KB | Output is correct |
27 | Correct | 119 ms | 3988 KB | Output is correct |
28 | Correct | 141 ms | 3980 KB | Output is correct |
29 | Correct | 144 ms | 4000 KB | Output is correct |
30 | Correct | 58 ms | 4072 KB | Output is correct |
31 | Correct | 62 ms | 4132 KB | Output is correct |
32 | Correct | 63 ms | 4172 KB | Output is correct |
33 | Correct | 1 ms | 316 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 320 KB | Output is correct |
36 | Correct | 557 ms | 18224 KB | Output is correct |
37 | Correct | 1176 ms | 24312 KB | Output is correct |
38 | Correct | 477 ms | 25616 KB | Output is correct |
39 | Correct | 351 ms | 12756 KB | Output is correct |
40 | Correct | 1097 ms | 24804 KB | Output is correct |
41 | Correct | 377 ms | 16376 KB | Output is correct |
42 | Correct | 327 ms | 16372 KB | Output is correct |
43 | Correct | 348 ms | 20052 KB | Output is correct |
44 | Correct | 468 ms | 25900 KB | Output is correct |
45 | Correct | 463 ms | 25904 KB | Output is correct |
46 | Correct | 651 ms | 25908 KB | Output is correct |
47 | Correct | 446 ms | 23756 KB | Output is correct |
48 | Correct | 1119 ms | 23880 KB | Output is correct |
49 | Correct | 342 ms | 21360 KB | Output is correct |
50 | Correct | 475 ms | 21392 KB | Output is correct |
51 | Correct | 269 ms | 22688 KB | Output is correct |
52 | Correct | 597 ms | 25780 KB | Output is correct |
53 | Correct | 1436 ms | 25780 KB | Output is correct |
54 | Correct | 280 ms | 24684 KB | Output is correct |
55 | Correct | 245 ms | 24684 KB | Output is correct |
56 | Correct | 282 ms | 24684 KB | Output is correct |
57 | Correct | 609 ms | 25900 KB | Output is correct |
58 | Correct | 1228 ms | 25772 KB | Output is correct |
59 | Correct | 1097 ms | 25512 KB | Output is correct |
60 | Correct | 1064 ms | 25788 KB | Output is correct |
61 | Correct | 689 ms | 25568 KB | Output is correct |
62 | Correct | 306 ms | 25396 KB | Output is correct |
63 | Correct | 1241 ms | 25508 KB | Output is correct |
64 | Correct | 591 ms | 25372 KB | Output is correct |
65 | Correct | 787 ms | 25164 KB | Output is correct |
66 | Correct | 1247 ms | 25016 KB | Output is correct |
67 | Correct | 1084 ms | 24892 KB | Output is correct |
68 | Correct | 553 ms | 24620 KB | Output is correct |
69 | Correct | 1430 ms | 24268 KB | Output is correct |
70 | Correct | 1589 ms | 23956 KB | Output is correct |
71 | Correct | 1077 ms | 35816 KB | Output is correct |
72 | Correct | 778 ms | 36212 KB | Output is correct |
73 | Correct | 1415 ms | 35788 KB | Output is correct |
74 | Correct | 1 ms | 212 KB | Output is correct |
75 | Correct | 1 ms | 328 KB | Output is correct |
76 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 324 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 316 KB | Output is correct |
18 | Correct | 52 ms | 3412 KB | Output is correct |
19 | Correct | 114 ms | 4180 KB | Output is correct |
20 | Correct | 117 ms | 4008 KB | Output is correct |
21 | Correct | 18 ms | 1356 KB | Output is correct |
22 | Correct | 113 ms | 4180 KB | Output is correct |
23 | Correct | 117 ms | 4168 KB | Output is correct |
24 | Correct | 28 ms | 2020 KB | Output is correct |
25 | Correct | 24 ms | 2012 KB | Output is correct |
26 | Correct | 109 ms | 3884 KB | Output is correct |
27 | Correct | 79 ms | 3880 KB | Output is correct |
28 | Correct | 79 ms | 3456 KB | Output is correct |
29 | Correct | 66 ms | 3468 KB | Output is correct |
30 | Correct | 100 ms | 3456 KB | Output is correct |
31 | Correct | 259 ms | 3056 KB | Output is correct |
32 | Correct | 57 ms | 3088 KB | Output is correct |
33 | Correct | 91 ms | 3012 KB | Output is correct |
34 | Correct | 57 ms | 4016 KB | Output is correct |
35 | Correct | 125 ms | 3996 KB | Output is correct |
36 | Correct | 130 ms | 4024 KB | Output is correct |
37 | Correct | 129 ms | 3976 KB | Output is correct |
38 | Correct | 88 ms | 3940 KB | Output is correct |
39 | Correct | 94 ms | 3968 KB | Output is correct |
40 | Correct | 116 ms | 4004 KB | Output is correct |
41 | Correct | 165 ms | 4004 KB | Output is correct |
42 | Correct | 124 ms | 3960 KB | Output is correct |
43 | Correct | 152 ms | 3924 KB | Output is correct |
44 | Correct | 119 ms | 3988 KB | Output is correct |
45 | Correct | 141 ms | 3980 KB | Output is correct |
46 | Correct | 144 ms | 4000 KB | Output is correct |
47 | Correct | 58 ms | 4072 KB | Output is correct |
48 | Correct | 62 ms | 4132 KB | Output is correct |
49 | Correct | 63 ms | 4172 KB | Output is correct |
50 | Correct | 1 ms | 316 KB | Output is correct |
51 | Correct | 1 ms | 340 KB | Output is correct |
52 | Correct | 1 ms | 320 KB | Output is correct |
53 | Correct | 557 ms | 18224 KB | Output is correct |
54 | Correct | 1176 ms | 24312 KB | Output is correct |
55 | Correct | 477 ms | 25616 KB | Output is correct |
56 | Correct | 351 ms | 12756 KB | Output is correct |
57 | Correct | 1097 ms | 24804 KB | Output is correct |
58 | Correct | 377 ms | 16376 KB | Output is correct |
59 | Correct | 327 ms | 16372 KB | Output is correct |
60 | Correct | 348 ms | 20052 KB | Output is correct |
61 | Correct | 468 ms | 25900 KB | Output is correct |
62 | Correct | 463 ms | 25904 KB | Output is correct |
63 | Correct | 651 ms | 25908 KB | Output is correct |
64 | Correct | 446 ms | 23756 KB | Output is correct |
65 | Correct | 1119 ms | 23880 KB | Output is correct |
66 | Correct | 342 ms | 21360 KB | Output is correct |
67 | Correct | 475 ms | 21392 KB | Output is correct |
68 | Correct | 269 ms | 22688 KB | Output is correct |
69 | Correct | 597 ms | 25780 KB | Output is correct |
70 | Correct | 1436 ms | 25780 KB | Output is correct |
71 | Correct | 280 ms | 24684 KB | Output is correct |
72 | Correct | 245 ms | 24684 KB | Output is correct |
73 | Correct | 282 ms | 24684 KB | Output is correct |
74 | Correct | 609 ms | 25900 KB | Output is correct |
75 | Correct | 1228 ms | 25772 KB | Output is correct |
76 | Correct | 1097 ms | 25512 KB | Output is correct |
77 | Correct | 1064 ms | 25788 KB | Output is correct |
78 | Correct | 689 ms | 25568 KB | Output is correct |
79 | Correct | 306 ms | 25396 KB | Output is correct |
80 | Correct | 1241 ms | 25508 KB | Output is correct |
81 | Correct | 591 ms | 25372 KB | Output is correct |
82 | Correct | 787 ms | 25164 KB | Output is correct |
83 | Correct | 1247 ms | 25016 KB | Output is correct |
84 | Correct | 1084 ms | 24892 KB | Output is correct |
85 | Correct | 553 ms | 24620 KB | Output is correct |
86 | Correct | 1430 ms | 24268 KB | Output is correct |
87 | Correct | 1589 ms | 23956 KB | Output is correct |
88 | Correct | 1077 ms | 35816 KB | Output is correct |
89 | Correct | 778 ms | 36212 KB | Output is correct |
90 | Correct | 1415 ms | 35788 KB | Output is correct |
91 | Correct | 1 ms | 212 KB | Output is correct |
92 | Correct | 1 ms | 328 KB | Output is correct |
93 | Correct | 1 ms | 212 KB | Output is correct |
94 | Correct | 781 ms | 34932 KB | Output is correct |
95 | Correct | 1117 ms | 36360 KB | Output is correct |
96 | Correct | 330 ms | 36316 KB | Output is correct |
97 | Correct | 583 ms | 19448 KB | Output is correct |
98 | Correct | 347 ms | 12748 KB | Output is correct |
99 | Correct | 984 ms | 36320 KB | Output is correct |
100 | Correct | 355 ms | 18284 KB | Output is correct |
101 | Correct | 353 ms | 18320 KB | Output is correct |
102 | Correct | 295 ms | 25592 KB | Output is correct |
103 | Correct | 344 ms | 36888 KB | Output is correct |
104 | Correct | 472 ms | 36808 KB | Output is correct |
105 | Correct | 491 ms | 36792 KB | Output is correct |
106 | Correct | 1027 ms | 35028 KB | Output is correct |
107 | Correct | 1567 ms | 32348 KB | Output is correct |
108 | Correct | 662 ms | 27560 KB | Output is correct |
109 | Correct | 615 ms | 31872 KB | Output is correct |
110 | Correct | 1320 ms | 29964 KB | Output is correct |
111 | Correct | 483 ms | 36868 KB | Output is correct |
112 | Correct | 1222 ms | 36412 KB | Output is correct |
113 | Correct | 307 ms | 34448 KB | Output is correct |
114 | Correct | 290 ms | 34512 KB | Output is correct |
115 | Correct | 286 ms | 34540 KB | Output is correct |
116 | Correct | 331 ms | 36332 KB | Output is correct |
117 | Correct | 1565 ms | 36444 KB | Output is correct |
118 | Correct | 874 ms | 36428 KB | Output is correct |
119 | Correct | 1022 ms | 36332 KB | Output is correct |
120 | Correct | 901 ms | 36448 KB | Output is correct |
121 | Correct | 516 ms | 32356 KB | Output is correct |
122 | Correct | 996 ms | 36368 KB | Output is correct |
123 | Correct | 427 ms | 36032 KB | Output is correct |
124 | Correct | 1 ms | 216 KB | Output is correct |
125 | Correct | 0 ms | 340 KB | Output is correct |
126 | Correct | 0 ms | 212 KB | Output is correct |