#include <string>
#include <iostream>
#include <random>
#include <time.h>
#define int int64_t
using namespace std;
int getchar(char c)
{
if (c == 'A') return 0;
else if (c == 'C') return 1;
else if (c == 'G') return 2;
else return 3;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int N_attemps = 10;
int MOD = 1e9 + 7;
int n, m, k;
cin >> n >> m >> k;
mt19937 rng(time(0));
uniform_int_distribution<int> uni(0, 1e7);
vector<string> ip(n);
for (int i = 0; i < n; i++)
{
cin >> ip[i];
}
vector<int> res(n, 0);
for (int z = 0; z < N_attemps; z++)
{
int s = 0;
vector<int> svals(n);
for (int i = 0; i < n; i++)
{
svals[i] = uni(rng);
s += svals[i];
}
vector<vector<int>> table(m, vector<int>(4, 0));
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
table[j][getchar(ip[i][j])] = (table[j][getchar(ip[i][j])] + svals[i]) % MOD;
}
}
for (int i = 0; i < n; i++)
{
int ssum = 0;
for (int j = 0; j < m; j++)
{
int curr = 0;
for (int f = 0; f < 4; f++)
{
curr += table[j][f];
}
curr -= table[j][getchar(ip[i][j])];
ssum = (ssum + curr) % MOD;
}
if (ssum == (1LL*(s - svals[i])*k) % MOD) res[i]++;
}
}
int mmax = -1;
int mp = -1;
for (int i = 0; i < n; i++)
{
if (res[i] > mmax)
{
mmax = res[i];
mp = i;
}
}
cout << mp + 1 << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
552 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
380 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
431 ms |
3192 KB |
Output is correct |
2 |
Correct |
351 ms |
4088 KB |
Output is correct |
3 |
Correct |
502 ms |
3824 KB |
Output is correct |
4 |
Correct |
113 ms |
1272 KB |
Output is correct |
5 |
Correct |
514 ms |
3984 KB |
Output is correct |
6 |
Correct |
534 ms |
4088 KB |
Output is correct |
7 |
Correct |
230 ms |
1912 KB |
Output is correct |
8 |
Correct |
189 ms |
2040 KB |
Output is correct |
9 |
Correct |
490 ms |
3576 KB |
Output is correct |
10 |
Correct |
493 ms |
3704 KB |
Output is correct |
11 |
Correct |
428 ms |
3196 KB |
Output is correct |
12 |
Correct |
435 ms |
3320 KB |
Output is correct |
13 |
Correct |
427 ms |
3192 KB |
Output is correct |
14 |
Correct |
372 ms |
2936 KB |
Output is correct |
15 |
Correct |
397 ms |
2808 KB |
Output is correct |
16 |
Correct |
381 ms |
2936 KB |
Output is correct |
17 |
Correct |
507 ms |
3832 KB |
Output is correct |
18 |
Correct |
511 ms |
3832 KB |
Output is correct |
19 |
Correct |
514 ms |
3960 KB |
Output is correct |
20 |
Correct |
501 ms |
3704 KB |
Output is correct |
21 |
Correct |
509 ms |
3704 KB |
Output is correct |
22 |
Correct |
505 ms |
3832 KB |
Output is correct |
23 |
Correct |
502 ms |
3704 KB |
Output is correct |
24 |
Correct |
508 ms |
3704 KB |
Output is correct |
25 |
Correct |
503 ms |
3704 KB |
Output is correct |
26 |
Correct |
508 ms |
3832 KB |
Output is correct |
27 |
Correct |
507 ms |
3832 KB |
Output is correct |
28 |
Correct |
505 ms |
3708 KB |
Output is correct |
29 |
Correct |
507 ms |
3704 KB |
Output is correct |
30 |
Correct |
350 ms |
3960 KB |
Output is correct |
31 |
Correct |
360 ms |
3960 KB |
Output is correct |
32 |
Correct |
532 ms |
4088 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
6 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
431 ms |
3192 KB |
Output is correct |
2 |
Correct |
351 ms |
4088 KB |
Output is correct |
3 |
Correct |
502 ms |
3824 KB |
Output is correct |
4 |
Correct |
113 ms |
1272 KB |
Output is correct |
5 |
Correct |
514 ms |
3984 KB |
Output is correct |
6 |
Correct |
534 ms |
4088 KB |
Output is correct |
7 |
Correct |
230 ms |
1912 KB |
Output is correct |
8 |
Correct |
189 ms |
2040 KB |
Output is correct |
9 |
Correct |
490 ms |
3576 KB |
Output is correct |
10 |
Correct |
493 ms |
3704 KB |
Output is correct |
11 |
Correct |
428 ms |
3196 KB |
Output is correct |
12 |
Correct |
435 ms |
3320 KB |
Output is correct |
13 |
Correct |
427 ms |
3192 KB |
Output is correct |
14 |
Correct |
372 ms |
2936 KB |
Output is correct |
15 |
Correct |
397 ms |
2808 KB |
Output is correct |
16 |
Correct |
381 ms |
2936 KB |
Output is correct |
17 |
Correct |
507 ms |
3832 KB |
Output is correct |
18 |
Correct |
511 ms |
3832 KB |
Output is correct |
19 |
Correct |
514 ms |
3960 KB |
Output is correct |
20 |
Correct |
501 ms |
3704 KB |
Output is correct |
21 |
Correct |
509 ms |
3704 KB |
Output is correct |
22 |
Correct |
505 ms |
3832 KB |
Output is correct |
23 |
Correct |
502 ms |
3704 KB |
Output is correct |
24 |
Correct |
508 ms |
3704 KB |
Output is correct |
25 |
Correct |
503 ms |
3704 KB |
Output is correct |
26 |
Correct |
508 ms |
3832 KB |
Output is correct |
27 |
Correct |
507 ms |
3832 KB |
Output is correct |
28 |
Correct |
505 ms |
3708 KB |
Output is correct |
29 |
Correct |
507 ms |
3704 KB |
Output is correct |
30 |
Correct |
350 ms |
3960 KB |
Output is correct |
31 |
Correct |
360 ms |
3960 KB |
Output is correct |
32 |
Correct |
532 ms |
4088 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
6 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Execution timed out |
2082 ms |
18172 KB |
Time limit exceeded |
37 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
552 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
6 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
6 ms |
380 KB |
Output is correct |
11 |
Correct |
6 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
376 KB |
Output is correct |
15 |
Correct |
7 ms |
376 KB |
Output is correct |
16 |
Correct |
5 ms |
376 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
431 ms |
3192 KB |
Output is correct |
19 |
Correct |
351 ms |
4088 KB |
Output is correct |
20 |
Correct |
502 ms |
3824 KB |
Output is correct |
21 |
Correct |
113 ms |
1272 KB |
Output is correct |
22 |
Correct |
514 ms |
3984 KB |
Output is correct |
23 |
Correct |
534 ms |
4088 KB |
Output is correct |
24 |
Correct |
230 ms |
1912 KB |
Output is correct |
25 |
Correct |
189 ms |
2040 KB |
Output is correct |
26 |
Correct |
490 ms |
3576 KB |
Output is correct |
27 |
Correct |
493 ms |
3704 KB |
Output is correct |
28 |
Correct |
428 ms |
3196 KB |
Output is correct |
29 |
Correct |
435 ms |
3320 KB |
Output is correct |
30 |
Correct |
427 ms |
3192 KB |
Output is correct |
31 |
Correct |
372 ms |
2936 KB |
Output is correct |
32 |
Correct |
397 ms |
2808 KB |
Output is correct |
33 |
Correct |
381 ms |
2936 KB |
Output is correct |
34 |
Correct |
507 ms |
3832 KB |
Output is correct |
35 |
Correct |
511 ms |
3832 KB |
Output is correct |
36 |
Correct |
514 ms |
3960 KB |
Output is correct |
37 |
Correct |
501 ms |
3704 KB |
Output is correct |
38 |
Correct |
509 ms |
3704 KB |
Output is correct |
39 |
Correct |
505 ms |
3832 KB |
Output is correct |
40 |
Correct |
502 ms |
3704 KB |
Output is correct |
41 |
Correct |
508 ms |
3704 KB |
Output is correct |
42 |
Correct |
503 ms |
3704 KB |
Output is correct |
43 |
Correct |
508 ms |
3832 KB |
Output is correct |
44 |
Correct |
507 ms |
3832 KB |
Output is correct |
45 |
Correct |
505 ms |
3708 KB |
Output is correct |
46 |
Correct |
507 ms |
3704 KB |
Output is correct |
47 |
Correct |
350 ms |
3960 KB |
Output is correct |
48 |
Correct |
360 ms |
3960 KB |
Output is correct |
49 |
Correct |
532 ms |
4088 KB |
Output is correct |
50 |
Correct |
5 ms |
376 KB |
Output is correct |
51 |
Correct |
6 ms |
376 KB |
Output is correct |
52 |
Correct |
5 ms |
376 KB |
Output is correct |
53 |
Execution timed out |
2082 ms |
18172 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |