# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
162811 |
2019-11-09T19:45:56 Z |
faremy |
Genetics (BOI18_genetics) |
C++14 |
|
2000 ms |
668156 KB |
#include <iostream>
#include <algorithm>
#include <cstdlib>
const int MAXN = 4100;
const int MAXT = 16400;
long long dna[MAXN][MAXT];
long long unify[MAXN][MAXN];
long long randomVector[MAXN];
long long randDna[MAXT];
long long randDiff[MAXN];
long long randUnify[MAXN];
int search(int sequences, int size)
{
for (int iSeq = 0; iSeq < sequences; iSeq++)
randomVector[iSeq] = rand() * rand() * rand() * rand();
for (int iChar = 0; iChar < size; iChar++)
{
randDna[iChar] = 0;
for (int iSeq = 0; iSeq < sequences; iSeq++)
randDna[iChar] = randDna[iChar] + dna[iSeq][iChar] * randomVector[iSeq];
}
for (int iSeq = 0; iSeq < sequences; iSeq++)
{
randDiff[iSeq] = 0;
for (int iChar = 0; iChar < size; iChar++)
randDiff[iSeq] = randDiff[iSeq] + dna[iSeq][iChar] * randDna[iChar];
}
for (int iSeq = 0; iSeq < sequences; iSeq++)
{
randUnify[iSeq] = 0;
for (int jSeq = 0; jSeq < sequences; jSeq++)
randUnify[iSeq] = randUnify[iSeq] + unify[iSeq][jSeq] * randomVector[jSeq];
}
int answer = -1;
for (int iSeq = 0; iSeq < sequences; iSeq++)
if (randDiff[iSeq] == randUnify[iSeq])
{
if (answer == -1)
answer = iSeq;
else
return -1;
}
return answer;
}
int main()
{
std::ios::sync_with_stdio(false);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
int sequences, size, differences;
std::cin >> sequences >> size >> differences;
for (int iSeq = 0; iSeq < sequences; iSeq++)
for (int iChar = 0; iChar < size; iChar++)
{
char elem; std::cin >> elem;
for (int iTrs = 0; iTrs < 4; iTrs++)
dna[iSeq][4 * iChar + iTrs] = -1;
switch (elem)
{
case 'A':
dna[iSeq][4 * iChar] = 1;
break;
case 'G':
dna[iSeq][4 * iChar + 1] = 1;
break;
case 'C':
dna[iSeq][4 * iChar + 2] = 1;
break;
case 'T':
dna[iSeq][4 * iChar + 3] = 1;
break;
}
}
for (int iSeq = 0; iSeq < sequences; iSeq++)
{
for (int jSeq = 0; jSeq < sequences; jSeq++)
unify[iSeq][jSeq] = 4 * (size - differences);
unify[iSeq][iSeq] = 4 * size;
}
srand(42);
int answer = search(sequences, 4 * size);
while (answer == -1)
answer = search(sequences, 4 * size);
std::cout << answer + 1 << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1400 KB |
Output is correct |
2 |
Correct |
6 ms |
1528 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
1144 KB |
Output is correct |
5 |
Correct |
6 ms |
1404 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 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 |
6 ms |
1528 KB |
Output is correct |
11 |
Correct |
5 ms |
1272 KB |
Output is correct |
12 |
Correct |
6 ms |
1496 KB |
Output is correct |
13 |
Correct |
5 ms |
1528 KB |
Output is correct |
14 |
Correct |
5 ms |
1528 KB |
Output is correct |
15 |
Correct |
6 ms |
1528 KB |
Output is correct |
16 |
Correct |
6 ms |
1272 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
112700 KB |
Output is correct |
2 |
Correct |
371 ms |
141816 KB |
Output is correct |
3 |
Correct |
348 ms |
134392 KB |
Output is correct |
4 |
Correct |
59 ms |
40952 KB |
Output is correct |
5 |
Correct |
367 ms |
142004 KB |
Output is correct |
6 |
Correct |
367 ms |
141944 KB |
Output is correct |
7 |
Correct |
78 ms |
54520 KB |
Output is correct |
8 |
Correct |
75 ms |
54488 KB |
Output is correct |
9 |
Correct |
338 ms |
131492 KB |
Output is correct |
10 |
Correct |
334 ms |
131448 KB |
Output is correct |
11 |
Correct |
267 ms |
112504 KB |
Output is correct |
12 |
Correct |
278 ms |
113272 KB |
Output is correct |
13 |
Correct |
269 ms |
112632 KB |
Output is correct |
14 |
Correct |
198 ms |
94584 KB |
Output is correct |
15 |
Correct |
208 ms |
95660 KB |
Output is correct |
16 |
Correct |
228 ms |
100100 KB |
Output is correct |
17 |
Correct |
345 ms |
134776 KB |
Output is correct |
18 |
Correct |
336 ms |
133624 KB |
Output is correct |
19 |
Correct |
353 ms |
134980 KB |
Output is correct |
20 |
Correct |
334 ms |
132856 KB |
Output is correct |
21 |
Correct |
346 ms |
134648 KB |
Output is correct |
22 |
Correct |
344 ms |
133112 KB |
Output is correct |
23 |
Correct |
346 ms |
134136 KB |
Output is correct |
24 |
Correct |
342 ms |
133880 KB |
Output is correct |
25 |
Correct |
339 ms |
132880 KB |
Output is correct |
26 |
Correct |
337 ms |
134136 KB |
Output is correct |
27 |
Correct |
346 ms |
133112 KB |
Output is correct |
28 |
Correct |
337 ms |
133112 KB |
Output is correct |
29 |
Correct |
341 ms |
134008 KB |
Output is correct |
30 |
Correct |
370 ms |
141956 KB |
Output is correct |
31 |
Correct |
372 ms |
141976 KB |
Output is correct |
32 |
Correct |
364 ms |
141944 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
1528 KB |
Output is correct |
35 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
269 ms |
112700 KB |
Output is correct |
2 |
Correct |
371 ms |
141816 KB |
Output is correct |
3 |
Correct |
348 ms |
134392 KB |
Output is correct |
4 |
Correct |
59 ms |
40952 KB |
Output is correct |
5 |
Correct |
367 ms |
142004 KB |
Output is correct |
6 |
Correct |
367 ms |
141944 KB |
Output is correct |
7 |
Correct |
78 ms |
54520 KB |
Output is correct |
8 |
Correct |
75 ms |
54488 KB |
Output is correct |
9 |
Correct |
338 ms |
131492 KB |
Output is correct |
10 |
Correct |
334 ms |
131448 KB |
Output is correct |
11 |
Correct |
267 ms |
112504 KB |
Output is correct |
12 |
Correct |
278 ms |
113272 KB |
Output is correct |
13 |
Correct |
269 ms |
112632 KB |
Output is correct |
14 |
Correct |
198 ms |
94584 KB |
Output is correct |
15 |
Correct |
208 ms |
95660 KB |
Output is correct |
16 |
Correct |
228 ms |
100100 KB |
Output is correct |
17 |
Correct |
345 ms |
134776 KB |
Output is correct |
18 |
Correct |
336 ms |
133624 KB |
Output is correct |
19 |
Correct |
353 ms |
134980 KB |
Output is correct |
20 |
Correct |
334 ms |
132856 KB |
Output is correct |
21 |
Correct |
346 ms |
134648 KB |
Output is correct |
22 |
Correct |
344 ms |
133112 KB |
Output is correct |
23 |
Correct |
346 ms |
134136 KB |
Output is correct |
24 |
Correct |
342 ms |
133880 KB |
Output is correct |
25 |
Correct |
339 ms |
132880 KB |
Output is correct |
26 |
Correct |
337 ms |
134136 KB |
Output is correct |
27 |
Correct |
346 ms |
133112 KB |
Output is correct |
28 |
Correct |
337 ms |
133112 KB |
Output is correct |
29 |
Correct |
341 ms |
134008 KB |
Output is correct |
30 |
Correct |
370 ms |
141956 KB |
Output is correct |
31 |
Correct |
372 ms |
141976 KB |
Output is correct |
32 |
Correct |
364 ms |
141944 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
1528 KB |
Output is correct |
35 |
Correct |
5 ms |
504 KB |
Output is correct |
36 |
Correct |
1923 ms |
575932 KB |
Output is correct |
37 |
Execution timed out |
2112 ms |
668156 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1400 KB |
Output is correct |
2 |
Correct |
6 ms |
1528 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
1144 KB |
Output is correct |
5 |
Correct |
6 ms |
1404 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 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 |
6 ms |
1528 KB |
Output is correct |
11 |
Correct |
5 ms |
1272 KB |
Output is correct |
12 |
Correct |
6 ms |
1496 KB |
Output is correct |
13 |
Correct |
5 ms |
1528 KB |
Output is correct |
14 |
Correct |
5 ms |
1528 KB |
Output is correct |
15 |
Correct |
6 ms |
1528 KB |
Output is correct |
16 |
Correct |
6 ms |
1272 KB |
Output is correct |
17 |
Correct |
5 ms |
504 KB |
Output is correct |
18 |
Correct |
269 ms |
112700 KB |
Output is correct |
19 |
Correct |
371 ms |
141816 KB |
Output is correct |
20 |
Correct |
348 ms |
134392 KB |
Output is correct |
21 |
Correct |
59 ms |
40952 KB |
Output is correct |
22 |
Correct |
367 ms |
142004 KB |
Output is correct |
23 |
Correct |
367 ms |
141944 KB |
Output is correct |
24 |
Correct |
78 ms |
54520 KB |
Output is correct |
25 |
Correct |
75 ms |
54488 KB |
Output is correct |
26 |
Correct |
338 ms |
131492 KB |
Output is correct |
27 |
Correct |
334 ms |
131448 KB |
Output is correct |
28 |
Correct |
267 ms |
112504 KB |
Output is correct |
29 |
Correct |
278 ms |
113272 KB |
Output is correct |
30 |
Correct |
269 ms |
112632 KB |
Output is correct |
31 |
Correct |
198 ms |
94584 KB |
Output is correct |
32 |
Correct |
208 ms |
95660 KB |
Output is correct |
33 |
Correct |
228 ms |
100100 KB |
Output is correct |
34 |
Correct |
345 ms |
134776 KB |
Output is correct |
35 |
Correct |
336 ms |
133624 KB |
Output is correct |
36 |
Correct |
353 ms |
134980 KB |
Output is correct |
37 |
Correct |
334 ms |
132856 KB |
Output is correct |
38 |
Correct |
346 ms |
134648 KB |
Output is correct |
39 |
Correct |
344 ms |
133112 KB |
Output is correct |
40 |
Correct |
346 ms |
134136 KB |
Output is correct |
41 |
Correct |
342 ms |
133880 KB |
Output is correct |
42 |
Correct |
339 ms |
132880 KB |
Output is correct |
43 |
Correct |
337 ms |
134136 KB |
Output is correct |
44 |
Correct |
346 ms |
133112 KB |
Output is correct |
45 |
Correct |
337 ms |
133112 KB |
Output is correct |
46 |
Correct |
341 ms |
134008 KB |
Output is correct |
47 |
Correct |
370 ms |
141956 KB |
Output is correct |
48 |
Correct |
372 ms |
141976 KB |
Output is correct |
49 |
Correct |
364 ms |
141944 KB |
Output is correct |
50 |
Correct |
5 ms |
376 KB |
Output is correct |
51 |
Correct |
5 ms |
1528 KB |
Output is correct |
52 |
Correct |
5 ms |
504 KB |
Output is correct |
53 |
Correct |
1923 ms |
575932 KB |
Output is correct |
54 |
Execution timed out |
2112 ms |
668156 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |