#include <bits/stdc++.h>
using namespace std;
int func(char ch){
if(ch == 'A')
return 0;
if(ch == 'C')
return 1;
if(ch == 'G')
return 2;
return 3;
}
vector <int> v;
int mat[4][4100][4100];
long long aux[4][4100], rez[4100];
inline bool ok(int i, int m, int k, int n){
long long loc = 0;
for(int j = 0; j < n; j++){
if(j != i)
loc += 1LL * (m - k) * v[j];
else
loc += 1LL * m * v[j];
}
return loc == rez[i];
}
int main()
{
int n, m, k;
char ch;
cin >> n >> m >> k;
srand(time(NULL));
v.resize(n);
for(auto &e : v)
e = rand();
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> ch;
ch = func(ch);
mat[ch][i][j] = 1;
}
}
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
for(int cul = 0; cul < 4; cul++)
aux[cul][j] += 1LL * mat[cul][i][j] * v[i];
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
for(int cul = 0; cul < 4; cul++)
rez[i] += 1LL * mat[cul][i][j] * aux[cul][j];
int i = 0;
while(i < n && !ok(i, m, k, n)){
i++;
}
cout << i + 1;
return 0;
}
Compilation message
genetics.cpp: In function 'int main()':
genetics.cpp:43:19: warning: array subscript has type 'char' [-Wchar-subscripts]
mat[ch][i][j] = 1;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1272 KB |
Output is correct |
2 |
Correct |
7 ms |
2296 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
1528 KB |
Output is correct |
5 |
Correct |
6 ms |
2040 KB |
Output is correct |
6 |
Correct |
7 ms |
1400 KB |
Output is correct |
7 |
Correct |
6 ms |
1144 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
1656 KB |
Output is correct |
10 |
Correct |
7 ms |
2168 KB |
Output is correct |
11 |
Correct |
6 ms |
1144 KB |
Output is correct |
12 |
Correct |
7 ms |
2168 KB |
Output is correct |
13 |
Correct |
6 ms |
1400 KB |
Output is correct |
14 |
Correct |
6 ms |
1784 KB |
Output is correct |
15 |
Correct |
7 ms |
2296 KB |
Output is correct |
16 |
Correct |
6 ms |
1528 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
284 ms |
35576 KB |
Output is correct |
2 |
Correct |
346 ms |
43512 KB |
Output is correct |
3 |
Correct |
333 ms |
41336 KB |
Output is correct |
4 |
Correct |
82 ms |
15096 KB |
Output is correct |
5 |
Correct |
343 ms |
43472 KB |
Output is correct |
6 |
Correct |
345 ms |
43512 KB |
Output is correct |
7 |
Correct |
148 ms |
18808 KB |
Output is correct |
8 |
Correct |
150 ms |
18728 KB |
Output is correct |
9 |
Correct |
318 ms |
40696 KB |
Output is correct |
10 |
Correct |
313 ms |
40444 KB |
Output is correct |
11 |
Correct |
298 ms |
35616 KB |
Output is correct |
12 |
Correct |
275 ms |
35832 KB |
Output is correct |
13 |
Correct |
279 ms |
35712 KB |
Output is correct |
14 |
Correct |
244 ms |
30712 KB |
Output is correct |
15 |
Correct |
239 ms |
30968 KB |
Output is correct |
16 |
Correct |
245 ms |
31968 KB |
Output is correct |
17 |
Correct |
328 ms |
41460 KB |
Output is correct |
18 |
Correct |
330 ms |
41336 KB |
Output is correct |
19 |
Correct |
327 ms |
41464 KB |
Output is correct |
20 |
Correct |
321 ms |
40928 KB |
Output is correct |
21 |
Correct |
327 ms |
41504 KB |
Output is correct |
22 |
Correct |
327 ms |
41080 KB |
Output is correct |
23 |
Correct |
331 ms |
41336 KB |
Output is correct |
24 |
Correct |
327 ms |
41208 KB |
Output is correct |
25 |
Correct |
323 ms |
41080 KB |
Output is correct |
26 |
Correct |
331 ms |
41304 KB |
Output is correct |
27 |
Correct |
329 ms |
41208 KB |
Output is correct |
28 |
Correct |
325 ms |
40976 KB |
Output is correct |
29 |
Correct |
328 ms |
41464 KB |
Output is correct |
30 |
Correct |
345 ms |
43384 KB |
Output is correct |
31 |
Correct |
345 ms |
43516 KB |
Output is correct |
32 |
Correct |
343 ms |
43512 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 |
508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
284 ms |
35576 KB |
Output is correct |
2 |
Correct |
346 ms |
43512 KB |
Output is correct |
3 |
Correct |
333 ms |
41336 KB |
Output is correct |
4 |
Correct |
82 ms |
15096 KB |
Output is correct |
5 |
Correct |
343 ms |
43472 KB |
Output is correct |
6 |
Correct |
345 ms |
43512 KB |
Output is correct |
7 |
Correct |
148 ms |
18808 KB |
Output is correct |
8 |
Correct |
150 ms |
18728 KB |
Output is correct |
9 |
Correct |
318 ms |
40696 KB |
Output is correct |
10 |
Correct |
313 ms |
40444 KB |
Output is correct |
11 |
Correct |
298 ms |
35616 KB |
Output is correct |
12 |
Correct |
275 ms |
35832 KB |
Output is correct |
13 |
Correct |
279 ms |
35712 KB |
Output is correct |
14 |
Correct |
244 ms |
30712 KB |
Output is correct |
15 |
Correct |
239 ms |
30968 KB |
Output is correct |
16 |
Correct |
245 ms |
31968 KB |
Output is correct |
17 |
Correct |
328 ms |
41460 KB |
Output is correct |
18 |
Correct |
330 ms |
41336 KB |
Output is correct |
19 |
Correct |
327 ms |
41464 KB |
Output is correct |
20 |
Correct |
321 ms |
40928 KB |
Output is correct |
21 |
Correct |
327 ms |
41504 KB |
Output is correct |
22 |
Correct |
327 ms |
41080 KB |
Output is correct |
23 |
Correct |
331 ms |
41336 KB |
Output is correct |
24 |
Correct |
327 ms |
41208 KB |
Output is correct |
25 |
Correct |
323 ms |
41080 KB |
Output is correct |
26 |
Correct |
331 ms |
41304 KB |
Output is correct |
27 |
Correct |
329 ms |
41208 KB |
Output is correct |
28 |
Correct |
325 ms |
40976 KB |
Output is correct |
29 |
Correct |
328 ms |
41464 KB |
Output is correct |
30 |
Correct |
345 ms |
43384 KB |
Output is correct |
31 |
Correct |
345 ms |
43516 KB |
Output is correct |
32 |
Correct |
343 ms |
43512 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 |
508 KB |
Output is correct |
36 |
Correct |
1491 ms |
118356 KB |
Output is correct |
37 |
Correct |
1705 ms |
132472 KB |
Output is correct |
38 |
Correct |
1668 ms |
145272 KB |
Output is correct |
39 |
Correct |
633 ms |
80504 KB |
Output is correct |
40 |
Correct |
1706 ms |
148832 KB |
Output is correct |
41 |
Correct |
863 ms |
74616 KB |
Output is correct |
42 |
Correct |
849 ms |
74744 KB |
Output is correct |
43 |
Correct |
1229 ms |
123640 KB |
Output is correct |
44 |
Correct |
1697 ms |
148708 KB |
Output is correct |
45 |
Correct |
1729 ms |
148612 KB |
Output is correct |
46 |
Correct |
1689 ms |
148860 KB |
Output is correct |
47 |
Execution timed out |
1176 ms |
111440 KB |
Time limit exceeded (wall clock) |
48 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1272 KB |
Output is correct |
2 |
Correct |
7 ms |
2296 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
1528 KB |
Output is correct |
5 |
Correct |
6 ms |
2040 KB |
Output is correct |
6 |
Correct |
7 ms |
1400 KB |
Output is correct |
7 |
Correct |
6 ms |
1144 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
6 ms |
1656 KB |
Output is correct |
10 |
Correct |
7 ms |
2168 KB |
Output is correct |
11 |
Correct |
6 ms |
1144 KB |
Output is correct |
12 |
Correct |
7 ms |
2168 KB |
Output is correct |
13 |
Correct |
6 ms |
1400 KB |
Output is correct |
14 |
Correct |
6 ms |
1784 KB |
Output is correct |
15 |
Correct |
7 ms |
2296 KB |
Output is correct |
16 |
Correct |
6 ms |
1528 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
284 ms |
35576 KB |
Output is correct |
19 |
Correct |
346 ms |
43512 KB |
Output is correct |
20 |
Correct |
333 ms |
41336 KB |
Output is correct |
21 |
Correct |
82 ms |
15096 KB |
Output is correct |
22 |
Correct |
343 ms |
43472 KB |
Output is correct |
23 |
Correct |
345 ms |
43512 KB |
Output is correct |
24 |
Correct |
148 ms |
18808 KB |
Output is correct |
25 |
Correct |
150 ms |
18728 KB |
Output is correct |
26 |
Correct |
318 ms |
40696 KB |
Output is correct |
27 |
Correct |
313 ms |
40444 KB |
Output is correct |
28 |
Correct |
298 ms |
35616 KB |
Output is correct |
29 |
Correct |
275 ms |
35832 KB |
Output is correct |
30 |
Correct |
279 ms |
35712 KB |
Output is correct |
31 |
Correct |
244 ms |
30712 KB |
Output is correct |
32 |
Correct |
239 ms |
30968 KB |
Output is correct |
33 |
Correct |
245 ms |
31968 KB |
Output is correct |
34 |
Correct |
328 ms |
41460 KB |
Output is correct |
35 |
Correct |
330 ms |
41336 KB |
Output is correct |
36 |
Correct |
327 ms |
41464 KB |
Output is correct |
37 |
Correct |
321 ms |
40928 KB |
Output is correct |
38 |
Correct |
327 ms |
41504 KB |
Output is correct |
39 |
Correct |
327 ms |
41080 KB |
Output is correct |
40 |
Correct |
331 ms |
41336 KB |
Output is correct |
41 |
Correct |
327 ms |
41208 KB |
Output is correct |
42 |
Correct |
323 ms |
41080 KB |
Output is correct |
43 |
Correct |
331 ms |
41304 KB |
Output is correct |
44 |
Correct |
329 ms |
41208 KB |
Output is correct |
45 |
Correct |
325 ms |
40976 KB |
Output is correct |
46 |
Correct |
328 ms |
41464 KB |
Output is correct |
47 |
Correct |
345 ms |
43384 KB |
Output is correct |
48 |
Correct |
345 ms |
43516 KB |
Output is correct |
49 |
Correct |
343 ms |
43512 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 |
508 KB |
Output is correct |
53 |
Correct |
1491 ms |
118356 KB |
Output is correct |
54 |
Correct |
1705 ms |
132472 KB |
Output is correct |
55 |
Correct |
1668 ms |
145272 KB |
Output is correct |
56 |
Correct |
633 ms |
80504 KB |
Output is correct |
57 |
Correct |
1706 ms |
148832 KB |
Output is correct |
58 |
Correct |
863 ms |
74616 KB |
Output is correct |
59 |
Correct |
849 ms |
74744 KB |
Output is correct |
60 |
Correct |
1229 ms |
123640 KB |
Output is correct |
61 |
Correct |
1697 ms |
148708 KB |
Output is correct |
62 |
Correct |
1729 ms |
148612 KB |
Output is correct |
63 |
Correct |
1689 ms |
148860 KB |
Output is correct |
64 |
Execution timed out |
1176 ms |
111440 KB |
Time limit exceeded (wall clock) |
65 |
Halted |
0 ms |
0 KB |
- |