#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
const int N = 4105, K = 4, B = 63;
string s[N], let = "ACGT";
int a[N], b[N][K], mem[N][N];
bool banned[N];
ll w[4][N][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());
int bl_cnt = (m - 1) / B + 1;
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 / B] |= 1ll << (j % B);
}
}
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);
memset(mem, -1, sizeof(mem));
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) {
if (mem[i][j] == -1) {
mem[i][j] = m;
for (int h = 0; h < K; h++) {
for (int z = 0; z < bl_cnt; z++) {
mem[i][j] -= __builtin_popcountll(w[h][i][z] & w[h][j][z]);
}
}
mem[j][i] = mem[i][j];
}
if (mem[i][j] != 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:36:25: warning: array subscript has type 'char' [-Wchar-subscripts]
b[j][s[i][j]]++;
^
genetics.cpp:37:22: warning: array subscript has type 'char' [-Wchar-subscripts]
w[s[i][j]][i][j / B] |= 1ll << (j % B);
^
genetics.cpp:63:32: warning: array subscript has type 'char' [-Wchar-subscripts]
sum += b[j][s[i][j]];
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
67192 KB |
Output is correct |
2 |
Correct |
40 ms |
68088 KB |
Output is correct |
3 |
Correct |
40 ms |
66552 KB |
Output is correct |
4 |
Correct |
39 ms |
67320 KB |
Output is correct |
5 |
Correct |
40 ms |
67960 KB |
Output is correct |
6 |
Correct |
41 ms |
67320 KB |
Output is correct |
7 |
Correct |
39 ms |
67064 KB |
Output is correct |
8 |
Correct |
39 ms |
66424 KB |
Output is correct |
9 |
Correct |
39 ms |
67448 KB |
Output is correct |
10 |
Correct |
41 ms |
67960 KB |
Output is correct |
11 |
Correct |
40 ms |
67192 KB |
Output is correct |
12 |
Correct |
41 ms |
68088 KB |
Output is correct |
13 |
Correct |
39 ms |
67320 KB |
Output is correct |
14 |
Correct |
39 ms |
67704 KB |
Output is correct |
15 |
Correct |
41 ms |
68088 KB |
Output is correct |
16 |
Correct |
41 ms |
67576 KB |
Output is correct |
17 |
Correct |
39 ms |
66552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
197 ms |
82296 KB |
Output is correct |
2 |
Correct |
110 ms |
85496 KB |
Output is correct |
3 |
Correct |
107 ms |
84600 KB |
Output is correct |
4 |
Correct |
58 ms |
76792 KB |
Output is correct |
5 |
Correct |
114 ms |
85472 KB |
Output is correct |
6 |
Correct |
115 ms |
85496 KB |
Output is correct |
7 |
Correct |
69 ms |
74548 KB |
Output is correct |
8 |
Correct |
69 ms |
74616 KB |
Output is correct |
9 |
Correct |
352 ms |
84728 KB |
Output is correct |
10 |
Correct |
122 ms |
84600 KB |
Output is correct |
11 |
Correct |
319 ms |
82424 KB |
Output is correct |
12 |
Correct |
239 ms |
82424 KB |
Output is correct |
13 |
Correct |
139 ms |
82296 KB |
Output is correct |
14 |
Correct |
93 ms |
79992 KB |
Output is correct |
15 |
Correct |
170 ms |
80376 KB |
Output is correct |
16 |
Correct |
91 ms |
81528 KB |
Output is correct |
17 |
Correct |
108 ms |
84728 KB |
Output is correct |
18 |
Correct |
107 ms |
84600 KB |
Output is correct |
19 |
Correct |
106 ms |
84728 KB |
Output is correct |
20 |
Correct |
107 ms |
84472 KB |
Output is correct |
21 |
Correct |
107 ms |
84600 KB |
Output is correct |
22 |
Correct |
108 ms |
84472 KB |
Output is correct |
23 |
Correct |
109 ms |
84600 KB |
Output is correct |
24 |
Correct |
111 ms |
84600 KB |
Output is correct |
25 |
Correct |
107 ms |
84472 KB |
Output is correct |
26 |
Correct |
107 ms |
84600 KB |
Output is correct |
27 |
Correct |
110 ms |
84448 KB |
Output is correct |
28 |
Correct |
105 ms |
84516 KB |
Output is correct |
29 |
Correct |
109 ms |
84600 KB |
Output is correct |
30 |
Correct |
110 ms |
85496 KB |
Output is correct |
31 |
Correct |
110 ms |
85496 KB |
Output is correct |
32 |
Correct |
116 ms |
85496 KB |
Output is correct |
33 |
Correct |
37 ms |
66552 KB |
Output is correct |
34 |
Correct |
40 ms |
67320 KB |
Output is correct |
35 |
Correct |
39 ms |
66552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
197 ms |
82296 KB |
Output is correct |
2 |
Correct |
110 ms |
85496 KB |
Output is correct |
3 |
Correct |
107 ms |
84600 KB |
Output is correct |
4 |
Correct |
58 ms |
76792 KB |
Output is correct |
5 |
Correct |
114 ms |
85472 KB |
Output is correct |
6 |
Correct |
115 ms |
85496 KB |
Output is correct |
7 |
Correct |
69 ms |
74548 KB |
Output is correct |
8 |
Correct |
69 ms |
74616 KB |
Output is correct |
9 |
Correct |
352 ms |
84728 KB |
Output is correct |
10 |
Correct |
122 ms |
84600 KB |
Output is correct |
11 |
Correct |
319 ms |
82424 KB |
Output is correct |
12 |
Correct |
239 ms |
82424 KB |
Output is correct |
13 |
Correct |
139 ms |
82296 KB |
Output is correct |
14 |
Correct |
93 ms |
79992 KB |
Output is correct |
15 |
Correct |
170 ms |
80376 KB |
Output is correct |
16 |
Correct |
91 ms |
81528 KB |
Output is correct |
17 |
Correct |
108 ms |
84728 KB |
Output is correct |
18 |
Correct |
107 ms |
84600 KB |
Output is correct |
19 |
Correct |
106 ms |
84728 KB |
Output is correct |
20 |
Correct |
107 ms |
84472 KB |
Output is correct |
21 |
Correct |
107 ms |
84600 KB |
Output is correct |
22 |
Correct |
108 ms |
84472 KB |
Output is correct |
23 |
Correct |
109 ms |
84600 KB |
Output is correct |
24 |
Correct |
111 ms |
84600 KB |
Output is correct |
25 |
Correct |
107 ms |
84472 KB |
Output is correct |
26 |
Correct |
107 ms |
84600 KB |
Output is correct |
27 |
Correct |
110 ms |
84448 KB |
Output is correct |
28 |
Correct |
105 ms |
84516 KB |
Output is correct |
29 |
Correct |
109 ms |
84600 KB |
Output is correct |
30 |
Correct |
110 ms |
85496 KB |
Output is correct |
31 |
Correct |
110 ms |
85496 KB |
Output is correct |
32 |
Correct |
116 ms |
85496 KB |
Output is correct |
33 |
Correct |
37 ms |
66552 KB |
Output is correct |
34 |
Correct |
40 ms |
67320 KB |
Output is correct |
35 |
Correct |
39 ms |
66552 KB |
Output is correct |
36 |
Correct |
1677 ms |
116828 KB |
Output is correct |
37 |
Correct |
387 ms |
123188 KB |
Output is correct |
38 |
Correct |
372 ms |
122484 KB |
Output is correct |
39 |
Correct |
199 ms |
102648 KB |
Output is correct |
40 |
Correct |
387 ms |
123132 KB |
Output is correct |
41 |
Correct |
214 ms |
94840 KB |
Output is correct |
42 |
Correct |
213 ms |
94840 KB |
Output is correct |
43 |
Correct |
1192 ms |
111096 KB |
Output is correct |
44 |
Execution timed out |
2097 ms |
123768 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
39 ms |
67192 KB |
Output is correct |
2 |
Correct |
40 ms |
68088 KB |
Output is correct |
3 |
Correct |
40 ms |
66552 KB |
Output is correct |
4 |
Correct |
39 ms |
67320 KB |
Output is correct |
5 |
Correct |
40 ms |
67960 KB |
Output is correct |
6 |
Correct |
41 ms |
67320 KB |
Output is correct |
7 |
Correct |
39 ms |
67064 KB |
Output is correct |
8 |
Correct |
39 ms |
66424 KB |
Output is correct |
9 |
Correct |
39 ms |
67448 KB |
Output is correct |
10 |
Correct |
41 ms |
67960 KB |
Output is correct |
11 |
Correct |
40 ms |
67192 KB |
Output is correct |
12 |
Correct |
41 ms |
68088 KB |
Output is correct |
13 |
Correct |
39 ms |
67320 KB |
Output is correct |
14 |
Correct |
39 ms |
67704 KB |
Output is correct |
15 |
Correct |
41 ms |
68088 KB |
Output is correct |
16 |
Correct |
41 ms |
67576 KB |
Output is correct |
17 |
Correct |
39 ms |
66552 KB |
Output is correct |
18 |
Correct |
197 ms |
82296 KB |
Output is correct |
19 |
Correct |
110 ms |
85496 KB |
Output is correct |
20 |
Correct |
107 ms |
84600 KB |
Output is correct |
21 |
Correct |
58 ms |
76792 KB |
Output is correct |
22 |
Correct |
114 ms |
85472 KB |
Output is correct |
23 |
Correct |
115 ms |
85496 KB |
Output is correct |
24 |
Correct |
69 ms |
74548 KB |
Output is correct |
25 |
Correct |
69 ms |
74616 KB |
Output is correct |
26 |
Correct |
352 ms |
84728 KB |
Output is correct |
27 |
Correct |
122 ms |
84600 KB |
Output is correct |
28 |
Correct |
319 ms |
82424 KB |
Output is correct |
29 |
Correct |
239 ms |
82424 KB |
Output is correct |
30 |
Correct |
139 ms |
82296 KB |
Output is correct |
31 |
Correct |
93 ms |
79992 KB |
Output is correct |
32 |
Correct |
170 ms |
80376 KB |
Output is correct |
33 |
Correct |
91 ms |
81528 KB |
Output is correct |
34 |
Correct |
108 ms |
84728 KB |
Output is correct |
35 |
Correct |
107 ms |
84600 KB |
Output is correct |
36 |
Correct |
106 ms |
84728 KB |
Output is correct |
37 |
Correct |
107 ms |
84472 KB |
Output is correct |
38 |
Correct |
107 ms |
84600 KB |
Output is correct |
39 |
Correct |
108 ms |
84472 KB |
Output is correct |
40 |
Correct |
109 ms |
84600 KB |
Output is correct |
41 |
Correct |
111 ms |
84600 KB |
Output is correct |
42 |
Correct |
107 ms |
84472 KB |
Output is correct |
43 |
Correct |
107 ms |
84600 KB |
Output is correct |
44 |
Correct |
110 ms |
84448 KB |
Output is correct |
45 |
Correct |
105 ms |
84516 KB |
Output is correct |
46 |
Correct |
109 ms |
84600 KB |
Output is correct |
47 |
Correct |
110 ms |
85496 KB |
Output is correct |
48 |
Correct |
110 ms |
85496 KB |
Output is correct |
49 |
Correct |
116 ms |
85496 KB |
Output is correct |
50 |
Correct |
37 ms |
66552 KB |
Output is correct |
51 |
Correct |
40 ms |
67320 KB |
Output is correct |
52 |
Correct |
39 ms |
66552 KB |
Output is correct |
53 |
Correct |
1677 ms |
116828 KB |
Output is correct |
54 |
Correct |
387 ms |
123188 KB |
Output is correct |
55 |
Correct |
372 ms |
122484 KB |
Output is correct |
56 |
Correct |
199 ms |
102648 KB |
Output is correct |
57 |
Correct |
387 ms |
123132 KB |
Output is correct |
58 |
Correct |
214 ms |
94840 KB |
Output is correct |
59 |
Correct |
213 ms |
94840 KB |
Output is correct |
60 |
Correct |
1192 ms |
111096 KB |
Output is correct |
61 |
Execution timed out |
2097 ms |
123768 KB |
Time limit exceeded |
62 |
Halted |
0 ms |
0 KB |
- |