답안 #105908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105908 2019-04-15T15:34:46 Z Pajaraja Genetics (BOI18_genetics) C++17
74 / 100
2000 ms 171856 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,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<100;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<400;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 6 ms 1272 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 1272 KB Output is correct
5 Correct 6 ms 1400 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 6 ms 1148 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1660 KB Output is correct
13 Correct 5 ms 1272 KB Output is correct
14 Correct 6 ms 1272 KB Output is correct
15 Correct 5 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 130 ms 39080 KB Output is correct
2 Correct 83 ms 45692 KB Output is correct
3 Correct 105 ms 45820 KB Output is correct
4 Correct 35 ms 19064 KB Output is correct
5 Correct 73 ms 41464 KB Output is correct
6 Correct 82 ms 43384 KB Output is correct
7 Correct 45 ms 20472 KB Output is correct
8 Correct 41 ms 20216 KB Output is correct
9 Correct 65 ms 38392 KB Output is correct
10 Correct 122 ms 43384 KB Output is correct
11 Correct 89 ms 37112 KB Output is correct
12 Correct 60 ms 34172 KB Output is correct
13 Correct 76 ms 35064 KB Output is correct
14 Correct 90 ms 33656 KB Output is correct
15 Correct 61 ms 30200 KB Output is correct
16 Correct 62 ms 32248 KB Output is correct
17 Correct 93 ms 44408 KB Output is correct
18 Correct 66 ms 39032 KB Output is correct
19 Correct 91 ms 43640 KB Output is correct
20 Correct 73 ms 39928 KB Output is correct
21 Correct 104 ms 43468 KB Output is correct
22 Correct 98 ms 45176 KB Output is correct
23 Correct 103 ms 45816 KB Output is correct
24 Correct 99 ms 45432 KB Output is correct
25 Correct 73 ms 40316 KB Output is correct
26 Correct 84 ms 41976 KB Output is correct
27 Correct 79 ms 41336 KB Output is correct
28 Correct 79 ms 41200 KB Output is correct
29 Correct 97 ms 43896 KB Output is correct
30 Correct 57 ms 41336 KB Output is correct
31 Correct 58 ms 41208 KB Output is correct
32 Correct 71 ms 41208 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 6 ms 1272 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 39080 KB Output is correct
2 Correct 83 ms 45692 KB Output is correct
3 Correct 105 ms 45820 KB Output is correct
4 Correct 35 ms 19064 KB Output is correct
5 Correct 73 ms 41464 KB Output is correct
6 Correct 82 ms 43384 KB Output is correct
7 Correct 45 ms 20472 KB Output is correct
8 Correct 41 ms 20216 KB Output is correct
9 Correct 65 ms 38392 KB Output is correct
10 Correct 122 ms 43384 KB Output is correct
11 Correct 89 ms 37112 KB Output is correct
12 Correct 60 ms 34172 KB Output is correct
13 Correct 76 ms 35064 KB Output is correct
14 Correct 90 ms 33656 KB Output is correct
15 Correct 61 ms 30200 KB Output is correct
16 Correct 62 ms 32248 KB Output is correct
17 Correct 93 ms 44408 KB Output is correct
18 Correct 66 ms 39032 KB Output is correct
19 Correct 91 ms 43640 KB Output is correct
20 Correct 73 ms 39928 KB Output is correct
21 Correct 104 ms 43468 KB Output is correct
22 Correct 98 ms 45176 KB Output is correct
23 Correct 103 ms 45816 KB Output is correct
24 Correct 99 ms 45432 KB Output is correct
25 Correct 73 ms 40316 KB Output is correct
26 Correct 84 ms 41976 KB Output is correct
27 Correct 79 ms 41336 KB Output is correct
28 Correct 79 ms 41200 KB Output is correct
29 Correct 97 ms 43896 KB Output is correct
30 Correct 57 ms 41336 KB Output is correct
31 Correct 58 ms 41208 KB Output is correct
32 Correct 71 ms 41208 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 6 ms 1272 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 648 ms 139000 KB Output is correct
37 Correct 307 ms 156408 KB Output is correct
38 Correct 451 ms 162680 KB Output is correct
39 Correct 153 ms 81528 KB Output is correct
40 Correct 404 ms 160504 KB Output is correct
41 Correct 196 ms 81016 KB Output is correct
42 Correct 172 ms 78840 KB Output is correct
43 Correct 273 ms 126200 KB Output is correct
44 Correct 327 ms 152184 KB Output is correct
45 Correct 503 ms 160760 KB Output is correct
46 Correct 337 ms 151672 KB Output is correct
47 Correct 587 ms 140024 KB Output is correct
48 Correct 593 ms 143992 KB Output is correct
49 Correct 270 ms 115064 KB Output is correct
50 Correct 592 ms 123128 KB Output is correct
51 Correct 342 ms 136440 KB Output is correct
52 Correct 429 ms 159608 KB Output is correct
53 Correct 428 ms 160376 KB Output is correct
54 Correct 243 ms 147708 KB Output is correct
55 Correct 240 ms 148216 KB Output is correct
56 Correct 296 ms 147744 KB Output is correct
57 Correct 461 ms 163064 KB Output is correct
58 Correct 376 ms 155128 KB Output is correct
59 Correct 333 ms 150648 KB Output is correct
60 Correct 334 ms 150776 KB Output is correct
61 Correct 332 ms 150648 KB Output is correct
62 Correct 314 ms 148472 KB Output is correct
63 Correct 302 ms 148600 KB Output is correct
64 Correct 322 ms 150008 KB Output is correct
65 Correct 436 ms 159480 KB Output is correct
66 Correct 408 ms 158200 KB Output is correct
67 Correct 407 ms 158584 KB Output is correct
68 Correct 375 ms 154360 KB Output is correct
69 Correct 299 ms 147192 KB Output is correct
70 Correct 407 ms 158200 KB Output is correct
71 Correct 364 ms 153336 KB Output is correct
72 Correct 373 ms 155512 KB Output is correct
73 Correct 401 ms 157048 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 6 ms 1272 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 6 ms 1272 KB Output is correct
5 Correct 6 ms 1400 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 6 ms 1148 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1660 KB Output is correct
13 Correct 5 ms 1272 KB Output is correct
14 Correct 6 ms 1272 KB Output is correct
15 Correct 5 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 130 ms 39080 KB Output is correct
19 Correct 83 ms 45692 KB Output is correct
20 Correct 105 ms 45820 KB Output is correct
21 Correct 35 ms 19064 KB Output is correct
22 Correct 73 ms 41464 KB Output is correct
23 Correct 82 ms 43384 KB Output is correct
24 Correct 45 ms 20472 KB Output is correct
25 Correct 41 ms 20216 KB Output is correct
26 Correct 65 ms 38392 KB Output is correct
27 Correct 122 ms 43384 KB Output is correct
28 Correct 89 ms 37112 KB Output is correct
29 Correct 60 ms 34172 KB Output is correct
30 Correct 76 ms 35064 KB Output is correct
31 Correct 90 ms 33656 KB Output is correct
32 Correct 61 ms 30200 KB Output is correct
33 Correct 62 ms 32248 KB Output is correct
34 Correct 93 ms 44408 KB Output is correct
35 Correct 66 ms 39032 KB Output is correct
36 Correct 91 ms 43640 KB Output is correct
37 Correct 73 ms 39928 KB Output is correct
38 Correct 104 ms 43468 KB Output is correct
39 Correct 98 ms 45176 KB Output is correct
40 Correct 103 ms 45816 KB Output is correct
41 Correct 99 ms 45432 KB Output is correct
42 Correct 73 ms 40316 KB Output is correct
43 Correct 84 ms 41976 KB Output is correct
44 Correct 79 ms 41336 KB Output is correct
45 Correct 79 ms 41200 KB Output is correct
46 Correct 97 ms 43896 KB Output is correct
47 Correct 57 ms 41336 KB Output is correct
48 Correct 58 ms 41208 KB Output is correct
49 Correct 71 ms 41208 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 6 ms 1272 KB Output is correct
52 Correct 5 ms 376 KB Output is correct
53 Correct 648 ms 139000 KB Output is correct
54 Correct 307 ms 156408 KB Output is correct
55 Correct 451 ms 162680 KB Output is correct
56 Correct 153 ms 81528 KB Output is correct
57 Correct 404 ms 160504 KB Output is correct
58 Correct 196 ms 81016 KB Output is correct
59 Correct 172 ms 78840 KB Output is correct
60 Correct 273 ms 126200 KB Output is correct
61 Correct 327 ms 152184 KB Output is correct
62 Correct 503 ms 160760 KB Output is correct
63 Correct 337 ms 151672 KB Output is correct
64 Correct 587 ms 140024 KB Output is correct
65 Correct 593 ms 143992 KB Output is correct
66 Correct 270 ms 115064 KB Output is correct
67 Correct 592 ms 123128 KB Output is correct
68 Correct 342 ms 136440 KB Output is correct
69 Correct 429 ms 159608 KB Output is correct
70 Correct 428 ms 160376 KB Output is correct
71 Correct 243 ms 147708 KB Output is correct
72 Correct 240 ms 148216 KB Output is correct
73 Correct 296 ms 147744 KB Output is correct
74 Correct 461 ms 163064 KB Output is correct
75 Correct 376 ms 155128 KB Output is correct
76 Correct 333 ms 150648 KB Output is correct
77 Correct 334 ms 150776 KB Output is correct
78 Correct 332 ms 150648 KB Output is correct
79 Correct 314 ms 148472 KB Output is correct
80 Correct 302 ms 148600 KB Output is correct
81 Correct 322 ms 150008 KB Output is correct
82 Correct 436 ms 159480 KB Output is correct
83 Correct 408 ms 158200 KB Output is correct
84 Correct 407 ms 158584 KB Output is correct
85 Correct 375 ms 154360 KB Output is correct
86 Correct 299 ms 147192 KB Output is correct
87 Correct 407 ms 158200 KB Output is correct
88 Correct 364 ms 153336 KB Output is correct
89 Correct 373 ms 155512 KB Output is correct
90 Correct 401 ms 157048 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 400 ms 148988 KB Output is correct
95 Correct 501 ms 166264 KB Output is correct
96 Correct 752 ms 170104 KB Output is correct
97 Correct 399 ms 92664 KB Output is correct
98 Correct 231 ms 86008 KB Output is correct
99 Correct 424 ms 162552 KB Output is correct
100 Correct 292 ms 83744 KB Output is correct
101 Correct 239 ms 81528 KB Output is correct
102 Correct 310 ms 129400 KB Output is correct
103 Correct 402 ms 155952 KB Output is correct
104 Correct 946 ms 168184 KB Output is correct
105 Execution timed out 2091 ms 171856 KB Time limit exceeded
106 Halted 0 ms 0 KB -