# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62719 | 2018-07-29T21:44:09 Z | eriksuenderhauf | Genetics (BOI18_genetics) | C++11 | 1386 ms | 111736 KB |
#include <bits/stdc++.h> #define enl printf("\n") #define case(t) printf("Case #%d: ", (t)) #define ni(n) scanf("%d", &(n)) #define nl(n) scanf("%I64d", &(n)) #define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i]) #define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i]) #define pri(n) printf("%d\n", (n)) #define prl(n) printf("%I64d\n", (n)) #define pii pair<int, int> #define vii vector<pii> #define vi vector<int> #define pb push_back #define mp make_pair #define fi first #define se second typedef long long ll; const double pi = acos(-1); const int MOD = 1e9 + 7; const int INF = 1e9 + 7; const int MAXN = 5e3 + 5; const double eps = 1e-9; using namespace std; char str[MAXN][MAXN]; bitset<MAXN> a[MAXN][4]; int cnt[MAXN][4]; int vis[MAXN][MAXN]; int go(char c) { if (c == 'A') return 0; else if (c == 'C') return 1; else if (c == 'G') return 2; else if (c == 'T') return 3; } int main() { int n, m, k; ni(n), ni(m), ni(k); for (int i = 0; i < n; i++) { scanf("%s", str[i]); for (int j = 0; j < m; j++) { int cur = go(str[i][j]); a[i][cur][j] = 1; cnt[j][cur]++; vis[i][j] = -1; } for (int j = m; j < n; j++) vis[i][j] = -1; } for (int i = n - 1; i >= 0; i--) { int tmp = 0; for (int j = 0; j < m; j++) tmp += n - cnt[j][go(str[i][j])]; if (tmp != k * (n - 1)) continue; int fl = 0; for (int j = n - 1; j >= 0; j--) { if (i == j) continue; int val = 0; if (vis[i][j] != -1) val = vis[i][j]; else { for (int b = 0; b < 4; b++) { val += (a[i][b] ^ a[j][b]).count(); if (val > 2 * k) break; } vis[i][j] = val; vis[j][i] = val; } if (val != 2 * k) { fl = 1; break; } } if (fl) continue; return !pri(i + 1); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1272 KB | Output is correct |
2 | Correct | 5 ms | 1400 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 1144 KB | Output is correct |
5 | Correct | 6 ms | 1400 KB | Output is correct |
6 | Correct | 5 ms | 1400 KB | Output is correct |
7 | Correct | 5 ms | 888 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 1016 KB | Output is correct |
10 | Correct | 5 ms | 1400 KB | Output is correct |
11 | Correct | 5 ms | 1272 KB | Output is correct |
12 | Correct | 6 ms | 1400 KB | Output is correct |
13 | Correct | 5 ms | 1400 KB | Output is correct |
14 | Correct | 6 ms | 1400 KB | Output is correct |
15 | Correct | 5 ms | 1400 KB | Output is correct |
16 | Correct | 5 ms | 1400 KB | Output is correct |
17 | Correct | 5 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 27768 KB | Output is correct |
2 | Correct | 52 ms | 33528 KB | Output is correct |
3 | Correct | 57 ms | 31992 KB | Output is correct |
4 | Correct | 24 ms | 18296 KB | Output is correct |
5 | Correct | 76 ms | 33528 KB | Output is correct |
6 | Correct | 70 ms | 33528 KB | Output is correct |
7 | Correct | 28 ms | 14456 KB | Output is correct |
8 | Correct | 28 ms | 14456 KB | Output is correct |
9 | Correct | 417 ms | 31864 KB | Output is correct |
10 | Correct | 79 ms | 31736 KB | Output is correct |
11 | Correct | 230 ms | 27896 KB | Output is correct |
12 | Correct | 373 ms | 28152 KB | Output is correct |
13 | Correct | 171 ms | 27768 KB | Output is correct |
14 | Correct | 47 ms | 23928 KB | Output is correct |
15 | Correct | 125 ms | 24220 KB | Output is correct |
16 | Correct | 55 ms | 25976 KB | Output is correct |
17 | Correct | 59 ms | 32124 KB | Output is correct |
18 | Correct | 74 ms | 31864 KB | Output is correct |
19 | Correct | 61 ms | 32120 KB | Output is correct |
20 | Correct | 72 ms | 31736 KB | Output is correct |
21 | Correct | 63 ms | 31992 KB | Output is correct |
22 | Correct | 56 ms | 31864 KB | Output is correct |
23 | Correct | 54 ms | 31992 KB | Output is correct |
24 | Correct | 57 ms | 31864 KB | Output is correct |
25 | Correct | 70 ms | 31864 KB | Output is correct |
26 | Correct | 66 ms | 31992 KB | Output is correct |
27 | Correct | 67 ms | 31736 KB | Output is correct |
28 | Correct | 66 ms | 31736 KB | Output is correct |
29 | Correct | 60 ms | 31992 KB | Output is correct |
30 | Correct | 59 ms | 33528 KB | Output is correct |
31 | Correct | 54 ms | 33520 KB | Output is correct |
32 | Correct | 72 ms | 33528 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 6 ms | 1400 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 27768 KB | Output is correct |
2 | Correct | 52 ms | 33528 KB | Output is correct |
3 | Correct | 57 ms | 31992 KB | Output is correct |
4 | Correct | 24 ms | 18296 KB | Output is correct |
5 | Correct | 76 ms | 33528 KB | Output is correct |
6 | Correct | 70 ms | 33528 KB | Output is correct |
7 | Correct | 28 ms | 14456 KB | Output is correct |
8 | Correct | 28 ms | 14456 KB | Output is correct |
9 | Correct | 417 ms | 31864 KB | Output is correct |
10 | Correct | 79 ms | 31736 KB | Output is correct |
11 | Correct | 230 ms | 27896 KB | Output is correct |
12 | Correct | 373 ms | 28152 KB | Output is correct |
13 | Correct | 171 ms | 27768 KB | Output is correct |
14 | Correct | 47 ms | 23928 KB | Output is correct |
15 | Correct | 125 ms | 24220 KB | Output is correct |
16 | Correct | 55 ms | 25976 KB | Output is correct |
17 | Correct | 59 ms | 32124 KB | Output is correct |
18 | Correct | 74 ms | 31864 KB | Output is correct |
19 | Correct | 61 ms | 32120 KB | Output is correct |
20 | Correct | 72 ms | 31736 KB | Output is correct |
21 | Correct | 63 ms | 31992 KB | Output is correct |
22 | Correct | 56 ms | 31864 KB | Output is correct |
23 | Correct | 54 ms | 31992 KB | Output is correct |
24 | Correct | 57 ms | 31864 KB | Output is correct |
25 | Correct | 70 ms | 31864 KB | Output is correct |
26 | Correct | 66 ms | 31992 KB | Output is correct |
27 | Correct | 67 ms | 31736 KB | Output is correct |
28 | Correct | 66 ms | 31736 KB | Output is correct |
29 | Correct | 60 ms | 31992 KB | Output is correct |
30 | Correct | 59 ms | 33528 KB | Output is correct |
31 | Correct | 54 ms | 33520 KB | Output is correct |
32 | Correct | 72 ms | 33528 KB | Output is correct |
33 | Correct | 5 ms | 376 KB | Output is correct |
34 | Correct | 6 ms | 1400 KB | Output is correct |
35 | Correct | 5 ms | 376 KB | Output is correct |
36 | Correct | 321 ms | 97144 KB | Output is correct |
37 | Correct | 250 ms | 110840 KB | Output is correct |
38 | Correct | 238 ms | 108280 KB | Output is correct |
39 | Correct | 178 ms | 86392 KB | Output is correct |
40 | Correct | 281 ms | 110840 KB | Output is correct |
41 | Correct | 142 ms | 55544 KB | Output is correct |
42 | Correct | 185 ms | 55544 KB | Output is correct |
43 | Correct | 646 ms | 86392 KB | Output is correct |
44 | Correct | 769 ms | 110968 KB | Output is correct |
45 | Correct | 474 ms | 110968 KB | Output is correct |
46 | Correct | 511 ms | 110968 KB | Output is correct |
47 | Correct | 498 ms | 97016 KB | Output is correct |
48 | Correct | 548 ms | 97144 KB | Output is correct |
49 | Correct | 941 ms | 83324 KB | Output is correct |
50 | Correct | 208 ms | 83192 KB | Output is correct |
51 | Correct | 254 ms | 93560 KB | Output is correct |
52 | Correct | 251 ms | 108152 KB | Output is correct |
53 | Correct | 254 ms | 108000 KB | Output is correct |
54 | Correct | 258 ms | 108408 KB | Output is correct |
55 | Correct | 213 ms | 108280 KB | Output is correct |
56 | Correct | 319 ms | 108252 KB | Output is correct |
57 | Correct | 235 ms | 108412 KB | Output is correct |
58 | Correct | 298 ms | 108408 KB | Output is correct |
59 | Correct | 314 ms | 107768 KB | Output is correct |
60 | Correct | 325 ms | 108536 KB | Output is correct |
61 | Correct | 315 ms | 107896 KB | Output is correct |
62 | Correct | 324 ms | 107384 KB | Output is correct |
63 | Correct | 333 ms | 108408 KB | Output is correct |
64 | Correct | 327 ms | 108664 KB | Output is correct |
65 | Correct | 259 ms | 108024 KB | Output is correct |
66 | Correct | 266 ms | 108152 KB | Output is correct |
67 | Correct | 269 ms | 108536 KB | Output is correct |
68 | Correct | 296 ms | 108448 KB | Output is correct |
69 | Correct | 342 ms | 107896 KB | Output is correct |
70 | Correct | 268 ms | 108280 KB | Output is correct |
71 | Correct | 295 ms | 107896 KB | Output is correct |
72 | Correct | 292 ms | 108664 KB | Output is correct |
73 | Correct | 267 ms | 107896 KB | Output is correct |
74 | Correct | 5 ms | 376 KB | Output is correct |
75 | Correct | 5 ms | 1400 KB | Output is correct |
76 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1272 KB | Output is correct |
2 | Correct | 5 ms | 1400 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 1144 KB | Output is correct |
5 | Correct | 6 ms | 1400 KB | Output is correct |
6 | Correct | 5 ms | 1400 KB | Output is correct |
7 | Correct | 5 ms | 888 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 1016 KB | Output is correct |
10 | Correct | 5 ms | 1400 KB | Output is correct |
11 | Correct | 5 ms | 1272 KB | Output is correct |
12 | Correct | 6 ms | 1400 KB | Output is correct |
13 | Correct | 5 ms | 1400 KB | Output is correct |
14 | Correct | 6 ms | 1400 KB | Output is correct |
15 | Correct | 5 ms | 1400 KB | Output is correct |
16 | Correct | 5 ms | 1400 KB | Output is correct |
17 | Correct | 5 ms | 380 KB | Output is correct |
18 | Correct | 50 ms | 27768 KB | Output is correct |
19 | Correct | 52 ms | 33528 KB | Output is correct |
20 | Correct | 57 ms | 31992 KB | Output is correct |
21 | Correct | 24 ms | 18296 KB | Output is correct |
22 | Correct | 76 ms | 33528 KB | Output is correct |
23 | Correct | 70 ms | 33528 KB | Output is correct |
24 | Correct | 28 ms | 14456 KB | Output is correct |
25 | Correct | 28 ms | 14456 KB | Output is correct |
26 | Correct | 417 ms | 31864 KB | Output is correct |
27 | Correct | 79 ms | 31736 KB | Output is correct |
28 | Correct | 230 ms | 27896 KB | Output is correct |
29 | Correct | 373 ms | 28152 KB | Output is correct |
30 | Correct | 171 ms | 27768 KB | Output is correct |
31 | Correct | 47 ms | 23928 KB | Output is correct |
32 | Correct | 125 ms | 24220 KB | Output is correct |
33 | Correct | 55 ms | 25976 KB | Output is correct |
34 | Correct | 59 ms | 32124 KB | Output is correct |
35 | Correct | 74 ms | 31864 KB | Output is correct |
36 | Correct | 61 ms | 32120 KB | Output is correct |
37 | Correct | 72 ms | 31736 KB | Output is correct |
38 | Correct | 63 ms | 31992 KB | Output is correct |
39 | Correct | 56 ms | 31864 KB | Output is correct |
40 | Correct | 54 ms | 31992 KB | Output is correct |
41 | Correct | 57 ms | 31864 KB | Output is correct |
42 | Correct | 70 ms | 31864 KB | Output is correct |
43 | Correct | 66 ms | 31992 KB | Output is correct |
44 | Correct | 67 ms | 31736 KB | Output is correct |
45 | Correct | 66 ms | 31736 KB | Output is correct |
46 | Correct | 60 ms | 31992 KB | Output is correct |
47 | Correct | 59 ms | 33528 KB | Output is correct |
48 | Correct | 54 ms | 33520 KB | Output is correct |
49 | Correct | 72 ms | 33528 KB | Output is correct |
50 | Correct | 5 ms | 376 KB | Output is correct |
51 | Correct | 6 ms | 1400 KB | Output is correct |
52 | Correct | 5 ms | 376 KB | Output is correct |
53 | Correct | 321 ms | 97144 KB | Output is correct |
54 | Correct | 250 ms | 110840 KB | Output is correct |
55 | Correct | 238 ms | 108280 KB | Output is correct |
56 | Correct | 178 ms | 86392 KB | Output is correct |
57 | Correct | 281 ms | 110840 KB | Output is correct |
58 | Correct | 142 ms | 55544 KB | Output is correct |
59 | Correct | 185 ms | 55544 KB | Output is correct |
60 | Correct | 646 ms | 86392 KB | Output is correct |
61 | Correct | 769 ms | 110968 KB | Output is correct |
62 | Correct | 474 ms | 110968 KB | Output is correct |
63 | Correct | 511 ms | 110968 KB | Output is correct |
64 | Correct | 498 ms | 97016 KB | Output is correct |
65 | Correct | 548 ms | 97144 KB | Output is correct |
66 | Correct | 941 ms | 83324 KB | Output is correct |
67 | Correct | 208 ms | 83192 KB | Output is correct |
68 | Correct | 254 ms | 93560 KB | Output is correct |
69 | Correct | 251 ms | 108152 KB | Output is correct |
70 | Correct | 254 ms | 108000 KB | Output is correct |
71 | Correct | 258 ms | 108408 KB | Output is correct |
72 | Correct | 213 ms | 108280 KB | Output is correct |
73 | Correct | 319 ms | 108252 KB | Output is correct |
74 | Correct | 235 ms | 108412 KB | Output is correct |
75 | Correct | 298 ms | 108408 KB | Output is correct |
76 | Correct | 314 ms | 107768 KB | Output is correct |
77 | Correct | 325 ms | 108536 KB | Output is correct |
78 | Correct | 315 ms | 107896 KB | Output is correct |
79 | Correct | 324 ms | 107384 KB | Output is correct |
80 | Correct | 333 ms | 108408 KB | Output is correct |
81 | Correct | 327 ms | 108664 KB | Output is correct |
82 | Correct | 259 ms | 108024 KB | Output is correct |
83 | Correct | 266 ms | 108152 KB | Output is correct |
84 | Correct | 269 ms | 108536 KB | Output is correct |
85 | Correct | 296 ms | 108448 KB | Output is correct |
86 | Correct | 342 ms | 107896 KB | Output is correct |
87 | Correct | 268 ms | 108280 KB | Output is correct |
88 | Correct | 295 ms | 107896 KB | Output is correct |
89 | Correct | 292 ms | 108664 KB | Output is correct |
90 | Correct | 267 ms | 107896 KB | Output is correct |
91 | Correct | 5 ms | 376 KB | Output is correct |
92 | Correct | 5 ms | 1400 KB | Output is correct |
93 | Correct | 5 ms | 376 KB | Output is correct |
94 | Correct | 459 ms | 104928 KB | Output is correct |
95 | Correct | 266 ms | 110864 KB | Output is correct |
96 | Correct | 290 ms | 108920 KB | Output is correct |
97 | Correct | 159 ms | 59384 KB | Output is correct |
98 | Correct | 154 ms | 86392 KB | Output is correct |
99 | Correct | 267 ms | 110772 KB | Output is correct |
100 | Correct | 174 ms | 55544 KB | Output is correct |
101 | Correct | 194 ms | 55772 KB | Output is correct |
102 | Correct | 499 ms | 86392 KB | Output is correct |
103 | Correct | 641 ms | 110968 KB | Output is correct |
104 | Correct | 537 ms | 110968 KB | Output is correct |
105 | Correct | 300 ms | 110840 KB | Output is correct |
106 | Correct | 838 ms | 105336 KB | Output is correct |
107 | Correct | 1386 ms | 97912 KB | Output is correct |
108 | Correct | 459 ms | 84040 KB | Output is correct |
109 | Correct | 397 ms | 96632 KB | Output is correct |
110 | Correct | 261 ms | 94456 KB | Output is correct |
111 | Correct | 391 ms | 111736 KB | Output is correct |
112 | Correct | 349 ms | 110328 KB | Output is correct |
113 | Correct | 233 ms | 109176 KB | Output is correct |
114 | Correct | 258 ms | 109048 KB | Output is correct |
115 | Correct | 321 ms | 109176 KB | Output is correct |
116 | Correct | 321 ms | 110200 KB | Output is correct |
117 | Correct | 342 ms | 110456 KB | Output is correct |
118 | Correct | 350 ms | 110328 KB | Output is correct |
119 | Correct | 380 ms | 109948 KB | Output is correct |
120 | Correct | 330 ms | 110328 KB | Output is correct |
121 | Correct | 311 ms | 97784 KB | Output is correct |
122 | Correct | 250 ms | 111480 KB | Output is correct |
123 | Correct | 239 ms | 109048 KB | Output is correct |
124 | Correct | 5 ms | 504 KB | Output is correct |
125 | Correct | 5 ms | 1400 KB | Output is correct |
126 | Correct | 5 ms | 376 KB | Output is correct |