#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 = 3;
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 |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 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 |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 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 |
137 ms |
3192 KB |
Output is correct |
2 |
Correct |
116 ms |
3960 KB |
Output is correct |
3 |
Correct |
158 ms |
3708 KB |
Output is correct |
4 |
Correct |
39 ms |
1144 KB |
Output is correct |
5 |
Correct |
166 ms |
3980 KB |
Output is correct |
6 |
Correct |
164 ms |
4092 KB |
Output is correct |
7 |
Correct |
73 ms |
1912 KB |
Output is correct |
8 |
Correct |
62 ms |
1912 KB |
Output is correct |
9 |
Correct |
156 ms |
3704 KB |
Output is correct |
10 |
Correct |
153 ms |
3704 KB |
Output is correct |
11 |
Correct |
135 ms |
3192 KB |
Output is correct |
12 |
Correct |
133 ms |
3320 KB |
Output is correct |
13 |
Correct |
136 ms |
3296 KB |
Output is correct |
14 |
Correct |
116 ms |
2936 KB |
Output is correct |
15 |
Correct |
117 ms |
2808 KB |
Output is correct |
16 |
Correct |
120 ms |
2808 KB |
Output is correct |
17 |
Correct |
158 ms |
3832 KB |
Output is correct |
18 |
Correct |
160 ms |
3808 KB |
Output is correct |
19 |
Correct |
157 ms |
3832 KB |
Output is correct |
20 |
Correct |
158 ms |
3704 KB |
Output is correct |
21 |
Correct |
164 ms |
3708 KB |
Output is correct |
22 |
Correct |
159 ms |
3704 KB |
Output is correct |
23 |
Correct |
155 ms |
3832 KB |
Output is correct |
24 |
Correct |
159 ms |
3832 KB |
Output is correct |
25 |
Correct |
156 ms |
3704 KB |
Output is correct |
26 |
Correct |
159 ms |
3704 KB |
Output is correct |
27 |
Correct |
156 ms |
3800 KB |
Output is correct |
28 |
Correct |
159 ms |
3836 KB |
Output is correct |
29 |
Correct |
159 ms |
3704 KB |
Output is correct |
30 |
Correct |
113 ms |
3960 KB |
Output is correct |
31 |
Correct |
115 ms |
3832 KB |
Output is correct |
32 |
Correct |
172 ms |
3960 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
3192 KB |
Output is correct |
2 |
Correct |
116 ms |
3960 KB |
Output is correct |
3 |
Correct |
158 ms |
3708 KB |
Output is correct |
4 |
Correct |
39 ms |
1144 KB |
Output is correct |
5 |
Correct |
166 ms |
3980 KB |
Output is correct |
6 |
Correct |
164 ms |
4092 KB |
Output is correct |
7 |
Correct |
73 ms |
1912 KB |
Output is correct |
8 |
Correct |
62 ms |
1912 KB |
Output is correct |
9 |
Correct |
156 ms |
3704 KB |
Output is correct |
10 |
Correct |
153 ms |
3704 KB |
Output is correct |
11 |
Correct |
135 ms |
3192 KB |
Output is correct |
12 |
Correct |
133 ms |
3320 KB |
Output is correct |
13 |
Correct |
136 ms |
3296 KB |
Output is correct |
14 |
Correct |
116 ms |
2936 KB |
Output is correct |
15 |
Correct |
117 ms |
2808 KB |
Output is correct |
16 |
Correct |
120 ms |
2808 KB |
Output is correct |
17 |
Correct |
158 ms |
3832 KB |
Output is correct |
18 |
Correct |
160 ms |
3808 KB |
Output is correct |
19 |
Correct |
157 ms |
3832 KB |
Output is correct |
20 |
Correct |
158 ms |
3704 KB |
Output is correct |
21 |
Correct |
164 ms |
3708 KB |
Output is correct |
22 |
Correct |
159 ms |
3704 KB |
Output is correct |
23 |
Correct |
155 ms |
3832 KB |
Output is correct |
24 |
Correct |
159 ms |
3832 KB |
Output is correct |
25 |
Correct |
156 ms |
3704 KB |
Output is correct |
26 |
Correct |
159 ms |
3704 KB |
Output is correct |
27 |
Correct |
156 ms |
3800 KB |
Output is correct |
28 |
Correct |
159 ms |
3836 KB |
Output is correct |
29 |
Correct |
159 ms |
3704 KB |
Output is correct |
30 |
Correct |
113 ms |
3960 KB |
Output is correct |
31 |
Correct |
115 ms |
3832 KB |
Output is correct |
32 |
Correct |
172 ms |
3960 KB |
Output is correct |
33 |
Correct |
5 ms |
376 KB |
Output is correct |
34 |
Correct |
5 ms |
376 KB |
Output is correct |
35 |
Correct |
5 ms |
376 KB |
Output is correct |
36 |
Correct |
741 ms |
17856 KB |
Output is correct |
37 |
Correct |
638 ms |
19976 KB |
Output is correct |
38 |
Correct |
823 ms |
20100 KB |
Output is correct |
39 |
Correct |
304 ms |
8440 KB |
Output is correct |
40 |
Correct |
835 ms |
22408 KB |
Output is correct |
41 |
Correct |
422 ms |
12144 KB |
Output is correct |
42 |
Correct |
404 ms |
12152 KB |
Output is correct |
43 |
Correct |
600 ms |
16800 KB |
Output is correct |
44 |
Correct |
845 ms |
22664 KB |
Output is correct |
45 |
Correct |
839 ms |
22460 KB |
Output is correct |
46 |
Correct |
846 ms |
22328 KB |
Output is correct |
47 |
Correct |
743 ms |
20216 KB |
Output is correct |
48 |
Correct |
742 ms |
18936 KB |
Output is correct |
49 |
Correct |
631 ms |
16404 KB |
Output is correct |
50 |
Correct |
626 ms |
16324 KB |
Output is correct |
51 |
Correct |
706 ms |
17664 KB |
Output is correct |
52 |
Correct |
827 ms |
20748 KB |
Output is correct |
53 |
Correct |
818 ms |
20652 KB |
Output is correct |
54 |
Correct |
599 ms |
19576 KB |
Output is correct |
55 |
Correct |
599 ms |
19584 KB |
Output is correct |
56 |
Correct |
808 ms |
19848 KB |
Output is correct |
57 |
Correct |
814 ms |
20796 KB |
Output is correct |
58 |
Correct |
827 ms |
20856 KB |
Output is correct |
59 |
Correct |
815 ms |
20624 KB |
Output is correct |
60 |
Correct |
832 ms |
20780 KB |
Output is correct |
61 |
Correct |
810 ms |
20352 KB |
Output is correct |
62 |
Correct |
812 ms |
20688 KB |
Output is correct |
63 |
Correct |
815 ms |
20516 KB |
Output is correct |
64 |
Correct |
818 ms |
20648 KB |
Output is correct |
65 |
Correct |
848 ms |
20352 KB |
Output is correct |
66 |
Correct |
824 ms |
20344 KB |
Output is correct |
67 |
Correct |
823 ms |
20544 KB |
Output is correct |
68 |
Correct |
819 ms |
20412 KB |
Output is correct |
69 |
Correct |
823 ms |
20352 KB |
Output is correct |
70 |
Correct |
823 ms |
20484 KB |
Output is correct |
71 |
Correct |
816 ms |
20412 KB |
Output is correct |
72 |
Correct |
821 ms |
20480 KB |
Output is correct |
73 |
Correct |
820 ms |
20356 KB |
Output is correct |
74 |
Correct |
5 ms |
376 KB |
Output is correct |
75 |
Correct |
5 ms |
376 KB |
Output is correct |
76 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 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 |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
376 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
5 ms |
376 KB |
Output is correct |
15 |
Correct |
5 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 |
137 ms |
3192 KB |
Output is correct |
19 |
Correct |
116 ms |
3960 KB |
Output is correct |
20 |
Correct |
158 ms |
3708 KB |
Output is correct |
21 |
Correct |
39 ms |
1144 KB |
Output is correct |
22 |
Correct |
166 ms |
3980 KB |
Output is correct |
23 |
Correct |
164 ms |
4092 KB |
Output is correct |
24 |
Correct |
73 ms |
1912 KB |
Output is correct |
25 |
Correct |
62 ms |
1912 KB |
Output is correct |
26 |
Correct |
156 ms |
3704 KB |
Output is correct |
27 |
Correct |
153 ms |
3704 KB |
Output is correct |
28 |
Correct |
135 ms |
3192 KB |
Output is correct |
29 |
Correct |
133 ms |
3320 KB |
Output is correct |
30 |
Correct |
136 ms |
3296 KB |
Output is correct |
31 |
Correct |
116 ms |
2936 KB |
Output is correct |
32 |
Correct |
117 ms |
2808 KB |
Output is correct |
33 |
Correct |
120 ms |
2808 KB |
Output is correct |
34 |
Correct |
158 ms |
3832 KB |
Output is correct |
35 |
Correct |
160 ms |
3808 KB |
Output is correct |
36 |
Correct |
157 ms |
3832 KB |
Output is correct |
37 |
Correct |
158 ms |
3704 KB |
Output is correct |
38 |
Correct |
164 ms |
3708 KB |
Output is correct |
39 |
Correct |
159 ms |
3704 KB |
Output is correct |
40 |
Correct |
155 ms |
3832 KB |
Output is correct |
41 |
Correct |
159 ms |
3832 KB |
Output is correct |
42 |
Correct |
156 ms |
3704 KB |
Output is correct |
43 |
Correct |
159 ms |
3704 KB |
Output is correct |
44 |
Correct |
156 ms |
3800 KB |
Output is correct |
45 |
Correct |
159 ms |
3836 KB |
Output is correct |
46 |
Correct |
159 ms |
3704 KB |
Output is correct |
47 |
Correct |
113 ms |
3960 KB |
Output is correct |
48 |
Correct |
115 ms |
3832 KB |
Output is correct |
49 |
Correct |
172 ms |
3960 KB |
Output is correct |
50 |
Correct |
5 ms |
376 KB |
Output is correct |
51 |
Correct |
5 ms |
376 KB |
Output is correct |
52 |
Correct |
5 ms |
376 KB |
Output is correct |
53 |
Correct |
741 ms |
17856 KB |
Output is correct |
54 |
Correct |
638 ms |
19976 KB |
Output is correct |
55 |
Correct |
823 ms |
20100 KB |
Output is correct |
56 |
Correct |
304 ms |
8440 KB |
Output is correct |
57 |
Correct |
835 ms |
22408 KB |
Output is correct |
58 |
Correct |
422 ms |
12144 KB |
Output is correct |
59 |
Correct |
404 ms |
12152 KB |
Output is correct |
60 |
Correct |
600 ms |
16800 KB |
Output is correct |
61 |
Correct |
845 ms |
22664 KB |
Output is correct |
62 |
Correct |
839 ms |
22460 KB |
Output is correct |
63 |
Correct |
846 ms |
22328 KB |
Output is correct |
64 |
Correct |
743 ms |
20216 KB |
Output is correct |
65 |
Correct |
742 ms |
18936 KB |
Output is correct |
66 |
Correct |
631 ms |
16404 KB |
Output is correct |
67 |
Correct |
626 ms |
16324 KB |
Output is correct |
68 |
Correct |
706 ms |
17664 KB |
Output is correct |
69 |
Correct |
827 ms |
20748 KB |
Output is correct |
70 |
Correct |
818 ms |
20652 KB |
Output is correct |
71 |
Correct |
599 ms |
19576 KB |
Output is correct |
72 |
Correct |
599 ms |
19584 KB |
Output is correct |
73 |
Correct |
808 ms |
19848 KB |
Output is correct |
74 |
Correct |
814 ms |
20796 KB |
Output is correct |
75 |
Correct |
827 ms |
20856 KB |
Output is correct |
76 |
Correct |
815 ms |
20624 KB |
Output is correct |
77 |
Correct |
832 ms |
20780 KB |
Output is correct |
78 |
Correct |
810 ms |
20352 KB |
Output is correct |
79 |
Correct |
812 ms |
20688 KB |
Output is correct |
80 |
Correct |
815 ms |
20516 KB |
Output is correct |
81 |
Correct |
818 ms |
20648 KB |
Output is correct |
82 |
Correct |
848 ms |
20352 KB |
Output is correct |
83 |
Correct |
824 ms |
20344 KB |
Output is correct |
84 |
Correct |
823 ms |
20544 KB |
Output is correct |
85 |
Correct |
819 ms |
20412 KB |
Output is correct |
86 |
Correct |
823 ms |
20352 KB |
Output is correct |
87 |
Correct |
823 ms |
20484 KB |
Output is correct |
88 |
Correct |
816 ms |
20412 KB |
Output is correct |
89 |
Correct |
821 ms |
20480 KB |
Output is correct |
90 |
Correct |
820 ms |
20356 KB |
Output is correct |
91 |
Correct |
5 ms |
376 KB |
Output is correct |
92 |
Correct |
5 ms |
376 KB |
Output is correct |
93 |
Correct |
5 ms |
376 KB |
Output is correct |
94 |
Correct |
915 ms |
19772 KB |
Output is correct |
95 |
Correct |
646 ms |
20444 KB |
Output is correct |
96 |
Correct |
947 ms |
20544 KB |
Output is correct |
97 |
Correct |
521 ms |
11344 KB |
Output is correct |
98 |
Correct |
379 ms |
7532 KB |
Output is correct |
99 |
Correct |
835 ms |
20424 KB |
Output is correct |
100 |
Correct |
486 ms |
10836 KB |
Output is correct |
101 |
Correct |
474 ms |
10784 KB |
Output is correct |
102 |
Correct |
686 ms |
14456 KB |
Output is correct |
103 |
Correct |
849 ms |
20864 KB |
Output is correct |
104 |
Correct |
975 ms |
20928 KB |
Output is correct |
105 |
Correct |
967 ms |
20924 KB |
Output is correct |
106 |
Correct |
923 ms |
20076 KB |
Output is correct |
107 |
Correct |
735 ms |
18768 KB |
Output is correct |
108 |
Correct |
632 ms |
15936 KB |
Output is correct |
109 |
Correct |
831 ms |
18364 KB |
Output is correct |
110 |
Correct |
802 ms |
17020 KB |
Output is correct |
111 |
Correct |
1060 ms |
21000 KB |
Output is correct |
112 |
Correct |
954 ms |
20668 KB |
Output is correct |
113 |
Correct |
604 ms |
19476 KB |
Output is correct |
114 |
Correct |
615 ms |
19444 KB |
Output is correct |
115 |
Correct |
922 ms |
19336 KB |
Output is correct |
116 |
Correct |
960 ms |
20668 KB |
Output is correct |
117 |
Correct |
980 ms |
20776 KB |
Output is correct |
118 |
Correct |
963 ms |
20872 KB |
Output is correct |
119 |
Correct |
952 ms |
20744 KB |
Output is correct |
120 |
Correct |
957 ms |
20664 KB |
Output is correct |
121 |
Correct |
743 ms |
18688 KB |
Output is correct |
122 |
Correct |
640 ms |
20616 KB |
Output is correct |
123 |
Correct |
827 ms |
20536 KB |
Output is correct |
124 |
Correct |
5 ms |
376 KB |
Output is correct |
125 |
Correct |
5 ms |
376 KB |
Output is correct |
126 |
Correct |
5 ms |
376 KB |
Output is correct |