#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const int N = 4100, K = 4;
string s[N], let = "ACGT";
int a[N], b[N][K];
bool banned[N];
bitset<N> w[K][N];
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
for (int i = 0; i < n; i++) {
a[i] = i;
while (s[i].empty())
getline(cin, s[i]);
for (int j = 0; j < m; j++) {
s[i][j] = find(all(let), s[i][j]) - let.begin();
b[j][s[i][j]]++;
w[s[i][j]][i][j] = 1;
}
}
for (int i = 0; i < m; i++) {
int sum = 0;
for (int j = 0; j < K; j++) {
sum += b[i][j];
}
for (int j = 0; j < K; j++) {
b[i][j] = sum - b[i][j];
}
}
shuffle(a, a + n, rng);
for (int h = 0; h < n; h++) {
int i = a[h];
if (banned[i])
continue;
ll sum = 0;
for (int j = 0; j < m; j++) {
sum += b[j][s[i][j]];
}
if (sum != k * (n - 1))
continue;
bool ok = true;
for (int j = 0; j < n; j++) {
if (i != j) {
int d = m;
for (int h = 0; h < K; h++) {
d -= (w[h][i] & w[h][j]).count();
}
if (d != k) {
banned[j] = 1;
ok = false;
}
}
}
if (ok) {
cout << i + 1;
return 0;
}
}
return 0;
}
Compilation message
genetics.cpp: In function 'int main()':
genetics.cpp:33:25: warning: array subscript has type 'char' [-Wchar-subscripts]
b[j][s[i][j]]++;
^
genetics.cpp:34:22: warning: array subscript has type 'char' [-Wchar-subscripts]
w[s[i][j]][i][j] = 1;
^
genetics.cpp:58:32: warning: array subscript has type 'char' [-Wchar-subscripts]
sum += b[j][s[i][j]];
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
632 KB |
Output is correct |
2 |
Correct |
6 ms |
760 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
760 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
6 ms |
632 KB |
Output is correct |
10 |
Correct |
6 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
760 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
14 |
Correct |
5 ms |
632 KB |
Output is correct |
15 |
Correct |
5 ms |
760 KB |
Output is correct |
16 |
Correct |
5 ms |
632 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
386 ms |
4728 KB |
Output is correct |
2 |
Correct |
66 ms |
5752 KB |
Output is correct |
3 |
Correct |
65 ms |
5488 KB |
Output is correct |
4 |
Correct |
19 ms |
2296 KB |
Output is correct |
5 |
Correct |
72 ms |
5752 KB |
Output is correct |
6 |
Correct |
73 ms |
5752 KB |
Output is correct |
7 |
Correct |
31 ms |
2808 KB |
Output is correct |
8 |
Correct |
36 ms |
2808 KB |
Output is correct |
9 |
Correct |
451 ms |
5496 KB |
Output is correct |
10 |
Correct |
405 ms |
5364 KB |
Output is correct |
11 |
Correct |
466 ms |
4856 KB |
Output is correct |
12 |
Correct |
152 ms |
4856 KB |
Output is correct |
13 |
Correct |
456 ms |
4820 KB |
Output is correct |
14 |
Correct |
203 ms |
4216 KB |
Output is correct |
15 |
Correct |
321 ms |
4344 KB |
Output is correct |
16 |
Correct |
51 ms |
4344 KB |
Output is correct |
17 |
Correct |
76 ms |
5496 KB |
Output is correct |
18 |
Correct |
66 ms |
5496 KB |
Output is correct |
19 |
Correct |
64 ms |
5496 KB |
Output is correct |
20 |
Correct |
68 ms |
5496 KB |
Output is correct |
21 |
Correct |
65 ms |
5496 KB |
Output is correct |
22 |
Correct |
66 ms |
5496 KB |
Output is correct |
23 |
Correct |
65 ms |
5496 KB |
Output is correct |
24 |
Correct |
67 ms |
5624 KB |
Output is correct |
25 |
Correct |
65 ms |
5484 KB |
Output is correct |
26 |
Correct |
66 ms |
5496 KB |
Output is correct |
27 |
Correct |
66 ms |
5496 KB |
Output is correct |
28 |
Correct |
67 ms |
5500 KB |
Output is correct |
29 |
Correct |
67 ms |
5496 KB |
Output is correct |
30 |
Correct |
66 ms |
5752 KB |
Output is correct |
31 |
Correct |
65 ms |
5752 KB |
Output is correct |
32 |
Correct |
69 ms |
5752 KB |
Output is correct |
33 |
Correct |
5 ms |
504 KB |
Output is correct |
34 |
Correct |
5 ms |
632 KB |
Output is correct |
35 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
386 ms |
4728 KB |
Output is correct |
2 |
Correct |
66 ms |
5752 KB |
Output is correct |
3 |
Correct |
65 ms |
5488 KB |
Output is correct |
4 |
Correct |
19 ms |
2296 KB |
Output is correct |
5 |
Correct |
72 ms |
5752 KB |
Output is correct |
6 |
Correct |
73 ms |
5752 KB |
Output is correct |
7 |
Correct |
31 ms |
2808 KB |
Output is correct |
8 |
Correct |
36 ms |
2808 KB |
Output is correct |
9 |
Correct |
451 ms |
5496 KB |
Output is correct |
10 |
Correct |
405 ms |
5364 KB |
Output is correct |
11 |
Correct |
466 ms |
4856 KB |
Output is correct |
12 |
Correct |
152 ms |
4856 KB |
Output is correct |
13 |
Correct |
456 ms |
4820 KB |
Output is correct |
14 |
Correct |
203 ms |
4216 KB |
Output is correct |
15 |
Correct |
321 ms |
4344 KB |
Output is correct |
16 |
Correct |
51 ms |
4344 KB |
Output is correct |
17 |
Correct |
76 ms |
5496 KB |
Output is correct |
18 |
Correct |
66 ms |
5496 KB |
Output is correct |
19 |
Correct |
64 ms |
5496 KB |
Output is correct |
20 |
Correct |
68 ms |
5496 KB |
Output is correct |
21 |
Correct |
65 ms |
5496 KB |
Output is correct |
22 |
Correct |
66 ms |
5496 KB |
Output is correct |
23 |
Correct |
65 ms |
5496 KB |
Output is correct |
24 |
Correct |
67 ms |
5624 KB |
Output is correct |
25 |
Correct |
65 ms |
5484 KB |
Output is correct |
26 |
Correct |
66 ms |
5496 KB |
Output is correct |
27 |
Correct |
66 ms |
5496 KB |
Output is correct |
28 |
Correct |
67 ms |
5500 KB |
Output is correct |
29 |
Correct |
67 ms |
5496 KB |
Output is correct |
30 |
Correct |
66 ms |
5752 KB |
Output is correct |
31 |
Correct |
65 ms |
5752 KB |
Output is correct |
32 |
Correct |
69 ms |
5752 KB |
Output is correct |
33 |
Correct |
5 ms |
504 KB |
Output is correct |
34 |
Correct |
5 ms |
632 KB |
Output is correct |
35 |
Correct |
5 ms |
504 KB |
Output is correct |
36 |
Correct |
1041 ms |
21240 KB |
Output is correct |
37 |
Correct |
333 ms |
25720 KB |
Output is correct |
38 |
Correct |
327 ms |
25848 KB |
Output is correct |
39 |
Correct |
124 ms |
12024 KB |
Output is correct |
40 |
Correct |
329 ms |
25980 KB |
Output is correct |
41 |
Correct |
166 ms |
14456 KB |
Output is correct |
42 |
Correct |
168 ms |
14204 KB |
Output is correct |
43 |
Correct |
1234 ms |
19884 KB |
Output is correct |
44 |
Execution timed out |
2048 ms |
26420 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
632 KB |
Output is correct |
2 |
Correct |
6 ms |
760 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
632 KB |
Output is correct |
5 |
Correct |
5 ms |
760 KB |
Output is correct |
6 |
Correct |
5 ms |
632 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
5 ms |
504 KB |
Output is correct |
9 |
Correct |
6 ms |
632 KB |
Output is correct |
10 |
Correct |
6 ms |
760 KB |
Output is correct |
11 |
Correct |
5 ms |
632 KB |
Output is correct |
12 |
Correct |
5 ms |
760 KB |
Output is correct |
13 |
Correct |
5 ms |
632 KB |
Output is correct |
14 |
Correct |
5 ms |
632 KB |
Output is correct |
15 |
Correct |
5 ms |
760 KB |
Output is correct |
16 |
Correct |
5 ms |
632 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
386 ms |
4728 KB |
Output is correct |
19 |
Correct |
66 ms |
5752 KB |
Output is correct |
20 |
Correct |
65 ms |
5488 KB |
Output is correct |
21 |
Correct |
19 ms |
2296 KB |
Output is correct |
22 |
Correct |
72 ms |
5752 KB |
Output is correct |
23 |
Correct |
73 ms |
5752 KB |
Output is correct |
24 |
Correct |
31 ms |
2808 KB |
Output is correct |
25 |
Correct |
36 ms |
2808 KB |
Output is correct |
26 |
Correct |
451 ms |
5496 KB |
Output is correct |
27 |
Correct |
405 ms |
5364 KB |
Output is correct |
28 |
Correct |
466 ms |
4856 KB |
Output is correct |
29 |
Correct |
152 ms |
4856 KB |
Output is correct |
30 |
Correct |
456 ms |
4820 KB |
Output is correct |
31 |
Correct |
203 ms |
4216 KB |
Output is correct |
32 |
Correct |
321 ms |
4344 KB |
Output is correct |
33 |
Correct |
51 ms |
4344 KB |
Output is correct |
34 |
Correct |
76 ms |
5496 KB |
Output is correct |
35 |
Correct |
66 ms |
5496 KB |
Output is correct |
36 |
Correct |
64 ms |
5496 KB |
Output is correct |
37 |
Correct |
68 ms |
5496 KB |
Output is correct |
38 |
Correct |
65 ms |
5496 KB |
Output is correct |
39 |
Correct |
66 ms |
5496 KB |
Output is correct |
40 |
Correct |
65 ms |
5496 KB |
Output is correct |
41 |
Correct |
67 ms |
5624 KB |
Output is correct |
42 |
Correct |
65 ms |
5484 KB |
Output is correct |
43 |
Correct |
66 ms |
5496 KB |
Output is correct |
44 |
Correct |
66 ms |
5496 KB |
Output is correct |
45 |
Correct |
67 ms |
5500 KB |
Output is correct |
46 |
Correct |
67 ms |
5496 KB |
Output is correct |
47 |
Correct |
66 ms |
5752 KB |
Output is correct |
48 |
Correct |
65 ms |
5752 KB |
Output is correct |
49 |
Correct |
69 ms |
5752 KB |
Output is correct |
50 |
Correct |
5 ms |
504 KB |
Output is correct |
51 |
Correct |
5 ms |
632 KB |
Output is correct |
52 |
Correct |
5 ms |
504 KB |
Output is correct |
53 |
Correct |
1041 ms |
21240 KB |
Output is correct |
54 |
Correct |
333 ms |
25720 KB |
Output is correct |
55 |
Correct |
327 ms |
25848 KB |
Output is correct |
56 |
Correct |
124 ms |
12024 KB |
Output is correct |
57 |
Correct |
329 ms |
25980 KB |
Output is correct |
58 |
Correct |
166 ms |
14456 KB |
Output is correct |
59 |
Correct |
168 ms |
14204 KB |
Output is correct |
60 |
Correct |
1234 ms |
19884 KB |
Output is correct |
61 |
Execution timed out |
2048 ms |
26420 KB |
Time limit exceeded |
62 |
Halted |
0 ms |
0 KB |
- |