Submission #105892

# Submission time Handle Problem Language Result Execution time Memory
105892 2019-04-15T15:09:27 Z Pajaraja Genetics (BOI18_genetics) C++17
74 / 100
2000 ms 157796 KB
#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;
bool check(int a,int b)
{
	int x=0;
	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); cin.tie(0);
	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(11122000);
	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<m;j++) skor+=(n-uc[arr[i][j]][j]);
		if(skor!=(n-1)*k) continue;
		for(int j=0;j<n;j++) if(i!=j) if(!check(i,j)) {propo=true; break;}
		if(propo) continue;
		printf("%d",i+1);
		return 0;
	}
}

Compilation message

genetics.cpp: In function 'int main()':
genetics.cpp:41:7: warning: unused variable 'st' [-Wunused-variable]
   int st=0;
       ^~
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1144 KB Output is correct
2 Correct 34 ms 1272 KB Output is correct
3 Correct 28 ms 376 KB Output is correct
4 Correct 35 ms 1144 KB Output is correct
5 Correct 29 ms 1144 KB Output is correct
6 Correct 33 ms 1144 KB Output is correct
7 Correct 35 ms 760 KB Output is correct
8 Correct 28 ms 376 KB Output is correct
9 Correct 31 ms 888 KB Output is correct
10 Correct 34 ms 1272 KB Output is correct
11 Correct 25 ms 1272 KB Output is correct
12 Correct 34 ms 1272 KB Output is correct
13 Correct 29 ms 1272 KB Output is correct
14 Correct 35 ms 1272 KB Output is correct
15 Correct 35 ms 1272 KB Output is correct
16 Correct 28 ms 1144 KB Output is correct
17 Correct 29 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 34552 KB Output is correct
2 Correct 132 ms 42232 KB Output is correct
3 Correct 147 ms 40312 KB Output is correct
4 Correct 58 ms 15480 KB Output is correct
5 Correct 144 ms 42104 KB Output is correct
6 Correct 144 ms 42104 KB Output is correct
7 Correct 93 ms 18300 KB Output is correct
8 Correct 94 ms 18400 KB Output is correct
9 Correct 137 ms 39160 KB Output is correct
10 Correct 150 ms 39160 KB Output is correct
11 Correct 135 ms 34296 KB Output is correct
12 Correct 129 ms 34680 KB Output is correct
13 Correct 131 ms 34296 KB Output is correct
14 Correct 124 ms 29688 KB Output is correct
15 Correct 119 ms 29944 KB Output is correct
16 Correct 119 ms 31224 KB Output is correct
17 Correct 140 ms 40184 KB Output is correct
18 Correct 136 ms 39928 KB Output is correct
19 Correct 142 ms 40256 KB Output is correct
20 Correct 139 ms 39672 KB Output is correct
21 Correct 141 ms 40056 KB Output is correct
22 Correct 141 ms 39800 KB Output is correct
23 Correct 144 ms 40152 KB Output is correct
24 Correct 145 ms 40076 KB Output is correct
25 Correct 136 ms 39672 KB Output is correct
26 Correct 140 ms 40180 KB Output is correct
27 Correct 138 ms 39800 KB Output is correct
28 Correct 144 ms 39672 KB Output is correct
29 Correct 144 ms 40056 KB Output is correct
30 Correct 128 ms 42176 KB Output is correct
31 Correct 128 ms 42104 KB Output is correct
32 Correct 142 ms 42104 KB Output is correct
33 Correct 28 ms 504 KB Output is correct
34 Correct 28 ms 1272 KB Output is correct
35 Correct 29 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 34552 KB Output is correct
2 Correct 132 ms 42232 KB Output is correct
3 Correct 147 ms 40312 KB Output is correct
4 Correct 58 ms 15480 KB Output is correct
5 Correct 144 ms 42104 KB Output is correct
6 Correct 144 ms 42104 KB Output is correct
7 Correct 93 ms 18300 KB Output is correct
8 Correct 94 ms 18400 KB Output is correct
9 Correct 137 ms 39160 KB Output is correct
10 Correct 150 ms 39160 KB Output is correct
11 Correct 135 ms 34296 KB Output is correct
12 Correct 129 ms 34680 KB Output is correct
13 Correct 131 ms 34296 KB Output is correct
14 Correct 124 ms 29688 KB Output is correct
15 Correct 119 ms 29944 KB Output is correct
16 Correct 119 ms 31224 KB Output is correct
17 Correct 140 ms 40184 KB Output is correct
18 Correct 136 ms 39928 KB Output is correct
19 Correct 142 ms 40256 KB Output is correct
20 Correct 139 ms 39672 KB Output is correct
21 Correct 141 ms 40056 KB Output is correct
22 Correct 141 ms 39800 KB Output is correct
23 Correct 144 ms 40152 KB Output is correct
24 Correct 145 ms 40076 KB Output is correct
25 Correct 136 ms 39672 KB Output is correct
26 Correct 140 ms 40180 KB Output is correct
27 Correct 138 ms 39800 KB Output is correct
28 Correct 144 ms 39672 KB Output is correct
29 Correct 144 ms 40056 KB Output is correct
30 Correct 128 ms 42176 KB Output is correct
31 Correct 128 ms 42104 KB Output is correct
32 Correct 142 ms 42104 KB Output is correct
33 Correct 28 ms 504 KB Output is correct
34 Correct 28 ms 1272 KB Output is correct
35 Correct 29 ms 376 KB Output is correct
36 Correct 754 ms 134328 KB Output is correct
37 Correct 412 ms 152696 KB Output is correct
38 Correct 461 ms 149116 KB Output is correct
39 Correct 205 ms 77432 KB Output is correct
40 Correct 460 ms 152568 KB Output is correct
41 Correct 288 ms 77432 KB Output is correct
42 Correct 276 ms 77432 KB Output is correct
43 Correct 366 ms 125304 KB Output is correct
44 Correct 453 ms 152528 KB Output is correct
45 Correct 523 ms 152384 KB Output is correct
46 Correct 474 ms 152132 KB Output is correct
47 Correct 607 ms 133772 KB Output is correct
48 Correct 541 ms 133368 KB Output is correct
49 Correct 385 ms 114680 KB Output is correct
50 Correct 620 ms 114680 KB Output is correct
51 Correct 401 ms 128632 KB Output is correct
52 Correct 448 ms 148472 KB Output is correct
53 Correct 447 ms 148364 KB Output is correct
54 Correct 371 ms 148604 KB Output is correct
55 Correct 367 ms 147832 KB Output is correct
56 Correct 428 ms 147960 KB Output is correct
57 Correct 451 ms 148088 KB Output is correct
58 Correct 443 ms 148192 KB Output is correct
59 Correct 438 ms 147320 KB Output is correct
60 Correct 452 ms 148600 KB Output is correct
61 Correct 444 ms 147964 KB Output is correct
62 Correct 450 ms 147448 KB Output is correct
63 Correct 441 ms 148220 KB Output is correct
64 Correct 454 ms 148472 KB Output is correct
65 Correct 447 ms 147964 KB Output is correct
66 Correct 460 ms 148216 KB Output is correct
67 Correct 449 ms 148728 KB Output is correct
68 Correct 446 ms 148604 KB Output is correct
69 Correct 445 ms 147960 KB Output is correct
70 Correct 445 ms 148344 KB Output is correct
71 Correct 450 ms 147448 KB Output is correct
72 Correct 439 ms 148600 KB Output is correct
73 Correct 458 ms 147704 KB Output is correct
74 Correct 29 ms 376 KB Output is correct
75 Correct 28 ms 1272 KB Output is correct
76 Correct 29 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1144 KB Output is correct
2 Correct 34 ms 1272 KB Output is correct
3 Correct 28 ms 376 KB Output is correct
4 Correct 35 ms 1144 KB Output is correct
5 Correct 29 ms 1144 KB Output is correct
6 Correct 33 ms 1144 KB Output is correct
7 Correct 35 ms 760 KB Output is correct
8 Correct 28 ms 376 KB Output is correct
9 Correct 31 ms 888 KB Output is correct
10 Correct 34 ms 1272 KB Output is correct
11 Correct 25 ms 1272 KB Output is correct
12 Correct 34 ms 1272 KB Output is correct
13 Correct 29 ms 1272 KB Output is correct
14 Correct 35 ms 1272 KB Output is correct
15 Correct 35 ms 1272 KB Output is correct
16 Correct 28 ms 1144 KB Output is correct
17 Correct 29 ms 504 KB Output is correct
18 Correct 157 ms 34552 KB Output is correct
19 Correct 132 ms 42232 KB Output is correct
20 Correct 147 ms 40312 KB Output is correct
21 Correct 58 ms 15480 KB Output is correct
22 Correct 144 ms 42104 KB Output is correct
23 Correct 144 ms 42104 KB Output is correct
24 Correct 93 ms 18300 KB Output is correct
25 Correct 94 ms 18400 KB Output is correct
26 Correct 137 ms 39160 KB Output is correct
27 Correct 150 ms 39160 KB Output is correct
28 Correct 135 ms 34296 KB Output is correct
29 Correct 129 ms 34680 KB Output is correct
30 Correct 131 ms 34296 KB Output is correct
31 Correct 124 ms 29688 KB Output is correct
32 Correct 119 ms 29944 KB Output is correct
33 Correct 119 ms 31224 KB Output is correct
34 Correct 140 ms 40184 KB Output is correct
35 Correct 136 ms 39928 KB Output is correct
36 Correct 142 ms 40256 KB Output is correct
37 Correct 139 ms 39672 KB Output is correct
38 Correct 141 ms 40056 KB Output is correct
39 Correct 141 ms 39800 KB Output is correct
40 Correct 144 ms 40152 KB Output is correct
41 Correct 145 ms 40076 KB Output is correct
42 Correct 136 ms 39672 KB Output is correct
43 Correct 140 ms 40180 KB Output is correct
44 Correct 138 ms 39800 KB Output is correct
45 Correct 144 ms 39672 KB Output is correct
46 Correct 144 ms 40056 KB Output is correct
47 Correct 128 ms 42176 KB Output is correct
48 Correct 128 ms 42104 KB Output is correct
49 Correct 142 ms 42104 KB Output is correct
50 Correct 28 ms 504 KB Output is correct
51 Correct 28 ms 1272 KB Output is correct
52 Correct 29 ms 376 KB Output is correct
53 Correct 754 ms 134328 KB Output is correct
54 Correct 412 ms 152696 KB Output is correct
55 Correct 461 ms 149116 KB Output is correct
56 Correct 205 ms 77432 KB Output is correct
57 Correct 460 ms 152568 KB Output is correct
58 Correct 288 ms 77432 KB Output is correct
59 Correct 276 ms 77432 KB Output is correct
60 Correct 366 ms 125304 KB Output is correct
61 Correct 453 ms 152528 KB Output is correct
62 Correct 523 ms 152384 KB Output is correct
63 Correct 474 ms 152132 KB Output is correct
64 Correct 607 ms 133772 KB Output is correct
65 Correct 541 ms 133368 KB Output is correct
66 Correct 385 ms 114680 KB Output is correct
67 Correct 620 ms 114680 KB Output is correct
68 Correct 401 ms 128632 KB Output is correct
69 Correct 448 ms 148472 KB Output is correct
70 Correct 447 ms 148364 KB Output is correct
71 Correct 371 ms 148604 KB Output is correct
72 Correct 367 ms 147832 KB Output is correct
73 Correct 428 ms 147960 KB Output is correct
74 Correct 451 ms 148088 KB Output is correct
75 Correct 443 ms 148192 KB Output is correct
76 Correct 438 ms 147320 KB Output is correct
77 Correct 452 ms 148600 KB Output is correct
78 Correct 444 ms 147964 KB Output is correct
79 Correct 450 ms 147448 KB Output is correct
80 Correct 441 ms 148220 KB Output is correct
81 Correct 454 ms 148472 KB Output is correct
82 Correct 447 ms 147964 KB Output is correct
83 Correct 460 ms 148216 KB Output is correct
84 Correct 449 ms 148728 KB Output is correct
85 Correct 446 ms 148604 KB Output is correct
86 Correct 445 ms 147960 KB Output is correct
87 Correct 445 ms 148344 KB Output is correct
88 Correct 450 ms 147448 KB Output is correct
89 Correct 439 ms 148600 KB Output is correct
90 Correct 458 ms 147704 KB Output is correct
91 Correct 29 ms 376 KB Output is correct
92 Correct 28 ms 1272 KB Output is correct
93 Correct 29 ms 376 KB Output is correct
94 Correct 804 ms 149368 KB Output is correct
95 Correct 689 ms 157796 KB Output is correct
96 Correct 781 ms 155128 KB Output is correct
97 Correct 593 ms 84856 KB Output is correct
98 Correct 335 ms 78584 KB Output is correct
99 Correct 472 ms 151604 KB Output is correct
100 Correct 566 ms 79480 KB Output is correct
101 Correct 538 ms 79480 KB Output is correct
102 Correct 619 ms 128504 KB Output is correct
103 Correct 480 ms 151416 KB Output is correct
104 Correct 927 ms 157688 KB Output is correct
105 Execution timed out 2091 ms 157688 KB Time limit exceeded
106 Halted 0 ms 0 KB -