#include <bits/stdc++.h>
using namespace std;
int uc[4][4107],k,m;
long long arr[4107][4107],ars[4107][1000];
bool c[4107],ps,p[4107][4107];
bool check(int a,int b)
{
int x=0; p[a][b]=true;
for(int i=0;i<=(ps?(m-1)/16:(m-1)/64);i++) x+=__builtin_popcountll(ars[a][i] xor ars[b][i]);
if(ps) x/=2;
if(x==k) return true;
return false;
}
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n>>m>>k;
string s;
for(int i=0;i<n;i++)
{
cin>>s;
for(int j=0;j<m;j++)
{
if(s[j]=='A') arr[i][j]=0;
if(s[j]=='C') arr[i][j]=1;
if(s[j]=='G') arr[i][j]=2;
if(s[j]=='T') arr[i][j]=3;
if(arr[i][j]>1) ps=true;
uc[arr[i][j]][j]++;
}
}
if(!ps) for(int i=0;i<n;i++) for(int j=0;j<m;j++) ars[i][j/64]+=(arr[i][j]<<(j%64));
else for(int i=0;i<n;i++) for(int j=0;j<m;j++) ars[i][j/16]+=(1LL<<(arr[i][j]+(j%16)*4));
int x=0,y=1;
mt19937 rng(2252522);
/*for(int ttt=0;ttt<400000;ttt++)
{
x=uniform_int_distribution<int>(0, n-1)(rng),y=uniform_int_distribution<int>(0,n-1)(rng);
if(x==y) continue;
int st=0;
if(!check(x,y)) {c[x]=c[y]=true;};
}*/
for(int i=0;i<n;i++) if(!c[i])
{
int skor=0;
bool propo=false;
for(int j=0;j<40;j++)
{
y=uniform_int_distribution<int>(0, n-1)(rng);
if(i==y || p[i][y] || p[y][i]) continue;
if(!check(i,y)) {c[i]=c[y]=true;}
}
if(c[i]) continue;
for(int j=0;j<m;j++) skor+=(n-uc[arr[i][j]][j]);
if(skor!=(n-1)*k) continue;
for(int j=0;j<1000;j++)
{
y=uniform_int_distribution<int>(0, n-1)(rng);
if(i==y || p[i][y] || p[y][i]) continue;
if(!check(i,y)) {propo=true; c[y]=true; break;}
}
for(int j=0;j<n;j++)
{
y=j;
if(i==y || p[i][y] || p[y][i]) continue;
if(!check(i,y)) {propo=true; c[y]=true; break;}
}
if(propo) continue;
printf("%d",i+1);
return 0;
}
}
Compilation message
genetics.cpp: In function 'int main()':
genetics.cpp:35:6: warning: unused variable 'x' [-Wunused-variable]
int x=0,y=1;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1144 KB |
Output is correct |
2 |
Correct |
5 ms |
1272 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1528 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 KB |
Output is correct |
7 |
Correct |
5 ms |
892 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
1148 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1272 KB |
Output is correct |
12 |
Correct |
6 ms |
1656 KB |
Output is correct |
13 |
Correct |
5 ms |
1276 KB |
Output is correct |
14 |
Correct |
5 ms |
1272 KB |
Output is correct |
15 |
Correct |
6 ms |
1272 KB |
Output is correct |
16 |
Correct |
5 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
39160 KB |
Output is correct |
2 |
Correct |
73 ms |
45816 KB |
Output is correct |
3 |
Correct |
88 ms |
45944 KB |
Output is correct |
4 |
Correct |
29 ms |
19192 KB |
Output is correct |
5 |
Correct |
71 ms |
41464 KB |
Output is correct |
6 |
Correct |
77 ms |
43384 KB |
Output is correct |
7 |
Correct |
40 ms |
20600 KB |
Output is correct |
8 |
Correct |
37 ms |
20216 KB |
Output is correct |
9 |
Correct |
65 ms |
38392 KB |
Output is correct |
10 |
Correct |
115 ms |
43352 KB |
Output is correct |
11 |
Correct |
91 ms |
37112 KB |
Output is correct |
12 |
Correct |
61 ms |
34040 KB |
Output is correct |
13 |
Correct |
78 ms |
35064 KB |
Output is correct |
14 |
Correct |
88 ms |
33632 KB |
Output is correct |
15 |
Correct |
60 ms |
30072 KB |
Output is correct |
16 |
Correct |
56 ms |
32120 KB |
Output is correct |
17 |
Correct |
82 ms |
44280 KB |
Output is correct |
18 |
Correct |
66 ms |
39032 KB |
Output is correct |
19 |
Correct |
80 ms |
43640 KB |
Output is correct |
20 |
Correct |
69 ms |
39800 KB |
Output is correct |
21 |
Correct |
78 ms |
43384 KB |
Output is correct |
22 |
Correct |
85 ms |
45176 KB |
Output is correct |
23 |
Correct |
90 ms |
45752 KB |
Output is correct |
24 |
Correct |
90 ms |
45432 KB |
Output is correct |
25 |
Correct |
71 ms |
40184 KB |
Output is correct |
26 |
Correct |
78 ms |
41848 KB |
Output is correct |
27 |
Correct |
74 ms |
41336 KB |
Output is correct |
28 |
Correct |
75 ms |
41208 KB |
Output is correct |
29 |
Correct |
89 ms |
43896 KB |
Output is correct |
30 |
Correct |
57 ms |
41336 KB |
Output is correct |
31 |
Correct |
58 ms |
41592 KB |
Output is correct |
32 |
Correct |
71 ms |
41336 KB |
Output is correct |
33 |
Correct |
6 ms |
504 KB |
Output is correct |
34 |
Correct |
5 ms |
1272 KB |
Output is correct |
35 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 ms |
39160 KB |
Output is correct |
2 |
Correct |
73 ms |
45816 KB |
Output is correct |
3 |
Correct |
88 ms |
45944 KB |
Output is correct |
4 |
Correct |
29 ms |
19192 KB |
Output is correct |
5 |
Correct |
71 ms |
41464 KB |
Output is correct |
6 |
Correct |
77 ms |
43384 KB |
Output is correct |
7 |
Correct |
40 ms |
20600 KB |
Output is correct |
8 |
Correct |
37 ms |
20216 KB |
Output is correct |
9 |
Correct |
65 ms |
38392 KB |
Output is correct |
10 |
Correct |
115 ms |
43352 KB |
Output is correct |
11 |
Correct |
91 ms |
37112 KB |
Output is correct |
12 |
Correct |
61 ms |
34040 KB |
Output is correct |
13 |
Correct |
78 ms |
35064 KB |
Output is correct |
14 |
Correct |
88 ms |
33632 KB |
Output is correct |
15 |
Correct |
60 ms |
30072 KB |
Output is correct |
16 |
Correct |
56 ms |
32120 KB |
Output is correct |
17 |
Correct |
82 ms |
44280 KB |
Output is correct |
18 |
Correct |
66 ms |
39032 KB |
Output is correct |
19 |
Correct |
80 ms |
43640 KB |
Output is correct |
20 |
Correct |
69 ms |
39800 KB |
Output is correct |
21 |
Correct |
78 ms |
43384 KB |
Output is correct |
22 |
Correct |
85 ms |
45176 KB |
Output is correct |
23 |
Correct |
90 ms |
45752 KB |
Output is correct |
24 |
Correct |
90 ms |
45432 KB |
Output is correct |
25 |
Correct |
71 ms |
40184 KB |
Output is correct |
26 |
Correct |
78 ms |
41848 KB |
Output is correct |
27 |
Correct |
74 ms |
41336 KB |
Output is correct |
28 |
Correct |
75 ms |
41208 KB |
Output is correct |
29 |
Correct |
89 ms |
43896 KB |
Output is correct |
30 |
Correct |
57 ms |
41336 KB |
Output is correct |
31 |
Correct |
58 ms |
41592 KB |
Output is correct |
32 |
Correct |
71 ms |
41336 KB |
Output is correct |
33 |
Correct |
6 ms |
504 KB |
Output is correct |
34 |
Correct |
5 ms |
1272 KB |
Output is correct |
35 |
Correct |
5 ms |
504 KB |
Output is correct |
36 |
Correct |
630 ms |
138872 KB |
Output is correct |
37 |
Correct |
284 ms |
156408 KB |
Output is correct |
38 |
Correct |
380 ms |
162424 KB |
Output is correct |
39 |
Correct |
139 ms |
81400 KB |
Output is correct |
40 |
Correct |
357 ms |
160380 KB |
Output is correct |
41 |
Correct |
178 ms |
80888 KB |
Output is correct |
42 |
Correct |
163 ms |
78712 KB |
Output is correct |
43 |
Correct |
267 ms |
126072 KB |
Output is correct |
44 |
Correct |
323 ms |
152056 KB |
Output is correct |
45 |
Correct |
502 ms |
160888 KB |
Output is correct |
46 |
Correct |
355 ms |
151672 KB |
Output is correct |
47 |
Correct |
585 ms |
140024 KB |
Output is correct |
48 |
Correct |
621 ms |
144120 KB |
Output is correct |
49 |
Correct |
272 ms |
115064 KB |
Output is correct |
50 |
Correct |
586 ms |
123000 KB |
Output is correct |
51 |
Correct |
304 ms |
136440 KB |
Output is correct |
52 |
Correct |
370 ms |
159736 KB |
Output is correct |
53 |
Correct |
371 ms |
160284 KB |
Output is correct |
54 |
Correct |
241 ms |
148216 KB |
Output is correct |
55 |
Correct |
246 ms |
149240 KB |
Output is correct |
56 |
Correct |
303 ms |
148152 KB |
Output is correct |
57 |
Correct |
386 ms |
163064 KB |
Output is correct |
58 |
Correct |
342 ms |
155204 KB |
Output is correct |
59 |
Correct |
314 ms |
150648 KB |
Output is correct |
60 |
Correct |
317 ms |
150780 KB |
Output is correct |
61 |
Correct |
336 ms |
150776 KB |
Output is correct |
62 |
Correct |
305 ms |
148472 KB |
Output is correct |
63 |
Correct |
304 ms |
148600 KB |
Output is correct |
64 |
Correct |
315 ms |
150008 KB |
Output is correct |
65 |
Correct |
372 ms |
159612 KB |
Output is correct |
66 |
Correct |
359 ms |
158200 KB |
Output is correct |
67 |
Correct |
356 ms |
158584 KB |
Output is correct |
68 |
Correct |
335 ms |
154488 KB |
Output is correct |
69 |
Correct |
296 ms |
147192 KB |
Output is correct |
70 |
Correct |
358 ms |
158200 KB |
Output is correct |
71 |
Correct |
332 ms |
153208 KB |
Output is correct |
72 |
Correct |
342 ms |
155512 KB |
Output is correct |
73 |
Correct |
352 ms |
156992 KB |
Output is correct |
74 |
Correct |
5 ms |
376 KB |
Output is correct |
75 |
Correct |
5 ms |
1272 KB |
Output is correct |
76 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
1144 KB |
Output is correct |
2 |
Correct |
5 ms |
1272 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
1272 KB |
Output is correct |
5 |
Correct |
5 ms |
1528 KB |
Output is correct |
6 |
Correct |
6 ms |
1528 KB |
Output is correct |
7 |
Correct |
5 ms |
892 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
1148 KB |
Output is correct |
10 |
Correct |
5 ms |
1400 KB |
Output is correct |
11 |
Correct |
5 ms |
1272 KB |
Output is correct |
12 |
Correct |
6 ms |
1656 KB |
Output is correct |
13 |
Correct |
5 ms |
1276 KB |
Output is correct |
14 |
Correct |
5 ms |
1272 KB |
Output is correct |
15 |
Correct |
6 ms |
1272 KB |
Output is correct |
16 |
Correct |
5 ms |
1144 KB |
Output is correct |
17 |
Correct |
5 ms |
376 KB |
Output is correct |
18 |
Correct |
125 ms |
39160 KB |
Output is correct |
19 |
Correct |
73 ms |
45816 KB |
Output is correct |
20 |
Correct |
88 ms |
45944 KB |
Output is correct |
21 |
Correct |
29 ms |
19192 KB |
Output is correct |
22 |
Correct |
71 ms |
41464 KB |
Output is correct |
23 |
Correct |
77 ms |
43384 KB |
Output is correct |
24 |
Correct |
40 ms |
20600 KB |
Output is correct |
25 |
Correct |
37 ms |
20216 KB |
Output is correct |
26 |
Correct |
65 ms |
38392 KB |
Output is correct |
27 |
Correct |
115 ms |
43352 KB |
Output is correct |
28 |
Correct |
91 ms |
37112 KB |
Output is correct |
29 |
Correct |
61 ms |
34040 KB |
Output is correct |
30 |
Correct |
78 ms |
35064 KB |
Output is correct |
31 |
Correct |
88 ms |
33632 KB |
Output is correct |
32 |
Correct |
60 ms |
30072 KB |
Output is correct |
33 |
Correct |
56 ms |
32120 KB |
Output is correct |
34 |
Correct |
82 ms |
44280 KB |
Output is correct |
35 |
Correct |
66 ms |
39032 KB |
Output is correct |
36 |
Correct |
80 ms |
43640 KB |
Output is correct |
37 |
Correct |
69 ms |
39800 KB |
Output is correct |
38 |
Correct |
78 ms |
43384 KB |
Output is correct |
39 |
Correct |
85 ms |
45176 KB |
Output is correct |
40 |
Correct |
90 ms |
45752 KB |
Output is correct |
41 |
Correct |
90 ms |
45432 KB |
Output is correct |
42 |
Correct |
71 ms |
40184 KB |
Output is correct |
43 |
Correct |
78 ms |
41848 KB |
Output is correct |
44 |
Correct |
74 ms |
41336 KB |
Output is correct |
45 |
Correct |
75 ms |
41208 KB |
Output is correct |
46 |
Correct |
89 ms |
43896 KB |
Output is correct |
47 |
Correct |
57 ms |
41336 KB |
Output is correct |
48 |
Correct |
58 ms |
41592 KB |
Output is correct |
49 |
Correct |
71 ms |
41336 KB |
Output is correct |
50 |
Correct |
6 ms |
504 KB |
Output is correct |
51 |
Correct |
5 ms |
1272 KB |
Output is correct |
52 |
Correct |
5 ms |
504 KB |
Output is correct |
53 |
Correct |
630 ms |
138872 KB |
Output is correct |
54 |
Correct |
284 ms |
156408 KB |
Output is correct |
55 |
Correct |
380 ms |
162424 KB |
Output is correct |
56 |
Correct |
139 ms |
81400 KB |
Output is correct |
57 |
Correct |
357 ms |
160380 KB |
Output is correct |
58 |
Correct |
178 ms |
80888 KB |
Output is correct |
59 |
Correct |
163 ms |
78712 KB |
Output is correct |
60 |
Correct |
267 ms |
126072 KB |
Output is correct |
61 |
Correct |
323 ms |
152056 KB |
Output is correct |
62 |
Correct |
502 ms |
160888 KB |
Output is correct |
63 |
Correct |
355 ms |
151672 KB |
Output is correct |
64 |
Correct |
585 ms |
140024 KB |
Output is correct |
65 |
Correct |
621 ms |
144120 KB |
Output is correct |
66 |
Correct |
272 ms |
115064 KB |
Output is correct |
67 |
Correct |
586 ms |
123000 KB |
Output is correct |
68 |
Correct |
304 ms |
136440 KB |
Output is correct |
69 |
Correct |
370 ms |
159736 KB |
Output is correct |
70 |
Correct |
371 ms |
160284 KB |
Output is correct |
71 |
Correct |
241 ms |
148216 KB |
Output is correct |
72 |
Correct |
246 ms |
149240 KB |
Output is correct |
73 |
Correct |
303 ms |
148152 KB |
Output is correct |
74 |
Correct |
386 ms |
163064 KB |
Output is correct |
75 |
Correct |
342 ms |
155204 KB |
Output is correct |
76 |
Correct |
314 ms |
150648 KB |
Output is correct |
77 |
Correct |
317 ms |
150780 KB |
Output is correct |
78 |
Correct |
336 ms |
150776 KB |
Output is correct |
79 |
Correct |
305 ms |
148472 KB |
Output is correct |
80 |
Correct |
304 ms |
148600 KB |
Output is correct |
81 |
Correct |
315 ms |
150008 KB |
Output is correct |
82 |
Correct |
372 ms |
159612 KB |
Output is correct |
83 |
Correct |
359 ms |
158200 KB |
Output is correct |
84 |
Correct |
356 ms |
158584 KB |
Output is correct |
85 |
Correct |
335 ms |
154488 KB |
Output is correct |
86 |
Correct |
296 ms |
147192 KB |
Output is correct |
87 |
Correct |
358 ms |
158200 KB |
Output is correct |
88 |
Correct |
332 ms |
153208 KB |
Output is correct |
89 |
Correct |
342 ms |
155512 KB |
Output is correct |
90 |
Correct |
352 ms |
156992 KB |
Output is correct |
91 |
Correct |
5 ms |
376 KB |
Output is correct |
92 |
Correct |
5 ms |
1272 KB |
Output is correct |
93 |
Correct |
5 ms |
376 KB |
Output is correct |
94 |
Correct |
392 ms |
148728 KB |
Output is correct |
95 |
Correct |
389 ms |
166392 KB |
Output is correct |
96 |
Correct |
540 ms |
170000 KB |
Output is correct |
97 |
Correct |
294 ms |
92984 KB |
Output is correct |
98 |
Correct |
182 ms |
86264 KB |
Output is correct |
99 |
Correct |
376 ms |
162808 KB |
Output is correct |
100 |
Correct |
230 ms |
83960 KB |
Output is correct |
101 |
Correct |
200 ms |
81784 KB |
Output is correct |
102 |
Correct |
285 ms |
129656 KB |
Output is correct |
103 |
Correct |
396 ms |
156152 KB |
Output is correct |
104 |
Correct |
905 ms |
168568 KB |
Output is correct |
105 |
Execution timed out |
2091 ms |
172280 KB |
Time limit exceeded |
106 |
Halted |
0 ms |
0 KB |
- |