Submission #62881

# Submission time Handle Problem Language Result Execution time Memory
62881 2018-07-30T16:18:20 Z IvanC Genetics (BOI18_genetics) C++17
100 / 100
959 ms 65528 KB
#include <bits/stdc++.h>
using namespace std;
typedef bitset<4101> bt;
 
const int MAXN = 4101;
 
bt matriz[MAXN][4],temporario;
char entrada[MAXN];
int N,M,K,marcado[MAXN],jafoi[MAXN][MAXN],somatorio1[MAXN][4],somatorio2[MAXN][4],noconjunto[MAXN];
 
knuth_b gen(1337);
int func(int i){
	return gen() % i;
}
 
int main(){
	scanf("%d %d %d",&N,&M,&K);
	K = M - K;
	int LIM = 2;
	vector<int> permutacao;
	for(int i = 1 ;i<=N;i++) permutacao.push_back(i);
	random_shuffle(permutacao.begin(),permutacao.end(),func);
	for(int i = 0;i<permutacao.size()/2;i++) noconjunto[permutacao[i]] = 1;
	for(int i = 1;i<=N;i++){
		scanf("%s",entrada);
		for(int j = 0;j<M;j++){
			if(entrada[j] == 'A'){
				matriz[i][0].set(j);
				somatorio1[j][0]++;
				if(noconjunto[i]) somatorio2[j][0]++;
			}
			else if(entrada[j] == 'C'){
				matriz[i][1].set(j);
				somatorio1[j][1]++;
				if(noconjunto[i]) somatorio2[j][1]++;
			}
			else if(entrada[j] == 'T'){
				matriz[i][2].set(j);
				somatorio1[j][2]++;
				if(noconjunto[i]) somatorio2[j][2]++;
				LIM = 4;
			}
			else{
				matriz[i][3].set(j);
				somatorio1[j][3]++;
				if(noconjunto[i]) somatorio2[j][3]++;
				LIM = 4;
			}
		}
	}
	for(int v : permutacao){
		if(marcado[v]) continue;
		int flag = 0;
		int total1 = 0,total2 = 0;
		for(int i = 0;i<M;i++){
			for(int j = 0;j<4;j++){
				if(matriz[v][j].test(i)){
					total1 += somatorio1[i][j];
					total2 += somatorio2[i][j];
					break;
				}
			}
		}
		total1 -= M;
		if((N-1)*K != total1) continue;
		if(noconjunto[v]) total2 -= M;
		if(((N/2) - noconjunto[v])*K != total2) continue;
		for(int u : permutacao){
			if(u == v || jafoi[u][v]) continue;
			jafoi[u][v] = jafoi[v][u] = 1;
			int qtd = 0;
			for(int i = 0;i<LIM;i++){
				temporario = matriz[u][i] & matriz[v][i];
				qtd += temporario.count();
			}
			if(qtd != K){
				marcado[u] = 1;
				marcado[v] = 1;
				flag = 1;
				break;
			}
		}
		if(!flag){
			printf("%d\n",v);
			return 0;
		}
	}
	return 0;
}

Compilation message

genetics.cpp: In function 'int main()':
genetics.cpp:23:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i<permutacao.size()/2;i++) noconjunto[permutacao[i]] = 1;
                ~^~~~~~~~~~~~~~~~~~~~
genetics.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&N,&M,&K);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
genetics.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",entrada);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 888 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 760 KB Output is correct
5 Correct 6 ms 888 KB Output is correct
6 Correct 5 ms 888 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 5 ms 888 KB Output is correct
11 Correct 5 ms 888 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 892 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
16 Correct 5 ms 888 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 14584 KB Output is correct
2 Correct 57 ms 11384 KB Output is correct
3 Correct 50 ms 10872 KB Output is correct
4 Correct 18 ms 7288 KB Output is correct
5 Correct 61 ms 11384 KB Output is correct
6 Correct 58 ms 11384 KB Output is correct
7 Correct 31 ms 5112 KB Output is correct
8 Correct 28 ms 5112 KB Output is correct
9 Correct 88 ms 19576 KB Output is correct
10 Correct 70 ms 16888 KB Output is correct
11 Correct 50 ms 14200 KB Output is correct
12 Correct 52 ms 10872 KB Output is correct
13 Correct 61 ms 10744 KB Output is correct
14 Correct 135 ms 12664 KB Output is correct
15 Correct 81 ms 10488 KB Output is correct
16 Correct 45 ms 9336 KB Output is correct
17 Correct 52 ms 10872 KB Output is correct
18 Correct 66 ms 10872 KB Output is correct
19 Correct 65 ms 10872 KB Output is correct
20 Correct 60 ms 10744 KB Output is correct
21 Correct 62 ms 10872 KB Output is correct
22 Correct 48 ms 10744 KB Output is correct
23 Correct 58 ms 10872 KB Output is correct
24 Correct 63 ms 10872 KB Output is correct
25 Correct 55 ms 10744 KB Output is correct
26 Correct 63 ms 10872 KB Output is correct
27 Correct 51 ms 10744 KB Output is correct
28 Correct 51 ms 10744 KB Output is correct
29 Correct 48 ms 10876 KB Output is correct
30 Correct 47 ms 11384 KB Output is correct
31 Correct 48 ms 11384 KB Output is correct
32 Correct 59 ms 11384 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 888 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 14584 KB Output is correct
2 Correct 57 ms 11384 KB Output is correct
3 Correct 50 ms 10872 KB Output is correct
4 Correct 18 ms 7288 KB Output is correct
5 Correct 61 ms 11384 KB Output is correct
6 Correct 58 ms 11384 KB Output is correct
7 Correct 31 ms 5112 KB Output is correct
8 Correct 28 ms 5112 KB Output is correct
9 Correct 88 ms 19576 KB Output is correct
10 Correct 70 ms 16888 KB Output is correct
11 Correct 50 ms 14200 KB Output is correct
12 Correct 52 ms 10872 KB Output is correct
13 Correct 61 ms 10744 KB Output is correct
14 Correct 135 ms 12664 KB Output is correct
15 Correct 81 ms 10488 KB Output is correct
16 Correct 45 ms 9336 KB Output is correct
17 Correct 52 ms 10872 KB Output is correct
18 Correct 66 ms 10872 KB Output is correct
19 Correct 65 ms 10872 KB Output is correct
20 Correct 60 ms 10744 KB Output is correct
21 Correct 62 ms 10872 KB Output is correct
22 Correct 48 ms 10744 KB Output is correct
23 Correct 58 ms 10872 KB Output is correct
24 Correct 63 ms 10872 KB Output is correct
25 Correct 55 ms 10744 KB Output is correct
26 Correct 63 ms 10872 KB Output is correct
27 Correct 51 ms 10744 KB Output is correct
28 Correct 51 ms 10744 KB Output is correct
29 Correct 48 ms 10876 KB Output is correct
30 Correct 47 ms 11384 KB Output is correct
31 Correct 48 ms 11384 KB Output is correct
32 Correct 59 ms 11384 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 888 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 671 ms 50576 KB Output is correct
37 Correct 206 ms 25336 KB Output is correct
38 Correct 271 ms 24952 KB Output is correct
39 Correct 111 ms 21368 KB Output is correct
40 Correct 307 ms 25340 KB Output is correct
41 Correct 161 ms 13048 KB Output is correct
42 Correct 156 ms 12920 KB Output is correct
43 Correct 406 ms 52088 KB Output is correct
44 Correct 398 ms 57616 KB Output is correct
45 Correct 328 ms 58520 KB Output is correct
46 Correct 370 ms 65528 KB Output is correct
47 Correct 331 ms 36984 KB Output is correct
48 Correct 548 ms 58748 KB Output is correct
49 Correct 163 ms 19216 KB Output is correct
50 Correct 245 ms 19320 KB Output is correct
51 Correct 260 ms 21496 KB Output is correct
52 Correct 257 ms 24776 KB Output is correct
53 Correct 246 ms 24824 KB Output is correct
54 Correct 251 ms 24824 KB Output is correct
55 Correct 241 ms 24824 KB Output is correct
56 Correct 283 ms 24952 KB Output is correct
57 Correct 309 ms 24824 KB Output is correct
58 Correct 227 ms 24824 KB Output is correct
59 Correct 209 ms 24696 KB Output is correct
60 Correct 303 ms 24824 KB Output is correct
61 Correct 204 ms 24956 KB Output is correct
62 Correct 291 ms 24568 KB Output is correct
63 Correct 300 ms 25080 KB Output is correct
64 Correct 306 ms 24824 KB Output is correct
65 Correct 297 ms 24696 KB Output is correct
66 Correct 221 ms 24824 KB Output is correct
67 Correct 221 ms 24824 KB Output is correct
68 Correct 211 ms 24824 KB Output is correct
69 Correct 207 ms 24696 KB Output is correct
70 Correct 222 ms 24836 KB Output is correct
71 Correct 312 ms 24696 KB Output is correct
72 Correct 200 ms 24952 KB Output is correct
73 Correct 236 ms 24696 KB Output is correct
74 Correct 5 ms 376 KB Output is correct
75 Correct 5 ms 888 KB Output is correct
76 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 888 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 760 KB Output is correct
5 Correct 6 ms 888 KB Output is correct
6 Correct 5 ms 888 KB Output is correct
7 Correct 5 ms 636 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 760 KB Output is correct
10 Correct 5 ms 888 KB Output is correct
11 Correct 5 ms 888 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 892 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
16 Correct 5 ms 888 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 64 ms 14584 KB Output is correct
19 Correct 57 ms 11384 KB Output is correct
20 Correct 50 ms 10872 KB Output is correct
21 Correct 18 ms 7288 KB Output is correct
22 Correct 61 ms 11384 KB Output is correct
23 Correct 58 ms 11384 KB Output is correct
24 Correct 31 ms 5112 KB Output is correct
25 Correct 28 ms 5112 KB Output is correct
26 Correct 88 ms 19576 KB Output is correct
27 Correct 70 ms 16888 KB Output is correct
28 Correct 50 ms 14200 KB Output is correct
29 Correct 52 ms 10872 KB Output is correct
30 Correct 61 ms 10744 KB Output is correct
31 Correct 135 ms 12664 KB Output is correct
32 Correct 81 ms 10488 KB Output is correct
33 Correct 45 ms 9336 KB Output is correct
34 Correct 52 ms 10872 KB Output is correct
35 Correct 66 ms 10872 KB Output is correct
36 Correct 65 ms 10872 KB Output is correct
37 Correct 60 ms 10744 KB Output is correct
38 Correct 62 ms 10872 KB Output is correct
39 Correct 48 ms 10744 KB Output is correct
40 Correct 58 ms 10872 KB Output is correct
41 Correct 63 ms 10872 KB Output is correct
42 Correct 55 ms 10744 KB Output is correct
43 Correct 63 ms 10872 KB Output is correct
44 Correct 51 ms 10744 KB Output is correct
45 Correct 51 ms 10744 KB Output is correct
46 Correct 48 ms 10876 KB Output is correct
47 Correct 47 ms 11384 KB Output is correct
48 Correct 48 ms 11384 KB Output is correct
49 Correct 59 ms 11384 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 888 KB Output is correct
52 Correct 5 ms 376 KB Output is correct
53 Correct 671 ms 50576 KB Output is correct
54 Correct 206 ms 25336 KB Output is correct
55 Correct 271 ms 24952 KB Output is correct
56 Correct 111 ms 21368 KB Output is correct
57 Correct 307 ms 25340 KB Output is correct
58 Correct 161 ms 13048 KB Output is correct
59 Correct 156 ms 12920 KB Output is correct
60 Correct 406 ms 52088 KB Output is correct
61 Correct 398 ms 57616 KB Output is correct
62 Correct 328 ms 58520 KB Output is correct
63 Correct 370 ms 65528 KB Output is correct
64 Correct 331 ms 36984 KB Output is correct
65 Correct 548 ms 58748 KB Output is correct
66 Correct 163 ms 19216 KB Output is correct
67 Correct 245 ms 19320 KB Output is correct
68 Correct 260 ms 21496 KB Output is correct
69 Correct 257 ms 24776 KB Output is correct
70 Correct 246 ms 24824 KB Output is correct
71 Correct 251 ms 24824 KB Output is correct
72 Correct 241 ms 24824 KB Output is correct
73 Correct 283 ms 24952 KB Output is correct
74 Correct 309 ms 24824 KB Output is correct
75 Correct 227 ms 24824 KB Output is correct
76 Correct 209 ms 24696 KB Output is correct
77 Correct 303 ms 24824 KB Output is correct
78 Correct 204 ms 24956 KB Output is correct
79 Correct 291 ms 24568 KB Output is correct
80 Correct 300 ms 25080 KB Output is correct
81 Correct 306 ms 24824 KB Output is correct
82 Correct 297 ms 24696 KB Output is correct
83 Correct 221 ms 24824 KB Output is correct
84 Correct 221 ms 24824 KB Output is correct
85 Correct 211 ms 24824 KB Output is correct
86 Correct 207 ms 24696 KB Output is correct
87 Correct 222 ms 24836 KB Output is correct
88 Correct 312 ms 24696 KB Output is correct
89 Correct 200 ms 24952 KB Output is correct
90 Correct 236 ms 24696 KB Output is correct
91 Correct 5 ms 376 KB Output is correct
92 Correct 5 ms 888 KB Output is correct
93 Correct 5 ms 376 KB Output is correct
94 Correct 405 ms 48120 KB Output is correct
95 Correct 261 ms 25336 KB Output is correct
96 Correct 357 ms 24956 KB Output is correct
97 Correct 187 ms 13816 KB Output is correct
98 Correct 104 ms 21368 KB Output is correct
99 Correct 290 ms 25464 KB Output is correct
100 Correct 147 ms 12920 KB Output is correct
101 Correct 203 ms 12920 KB Output is correct
102 Correct 267 ms 25720 KB Output is correct
103 Correct 516 ms 63536 KB Output is correct
104 Correct 310 ms 55784 KB Output is correct
105 Correct 508 ms 54648 KB Output is correct
106 Correct 959 ms 55988 KB Output is correct
107 Correct 371 ms 47352 KB Output is correct
108 Correct 230 ms 19192 KB Output is correct
109 Correct 240 ms 22048 KB Output is correct
110 Correct 300 ms 21624 KB Output is correct
111 Correct 273 ms 25332 KB Output is correct
112 Correct 364 ms 25080 KB Output is correct
113 Correct 264 ms 24824 KB Output is correct
114 Correct 228 ms 24824 KB Output is correct
115 Correct 356 ms 24824 KB Output is correct
116 Correct 324 ms 25080 KB Output is correct
117 Correct 346 ms 25208 KB Output is correct
118 Correct 363 ms 25080 KB Output is correct
119 Correct 251 ms 24988 KB Output is correct
120 Correct 263 ms 25084 KB Output is correct
121 Correct 674 ms 50472 KB Output is correct
122 Correct 210 ms 25336 KB Output is correct
123 Correct 275 ms 24824 KB Output is correct
124 Correct 5 ms 376 KB Output is correct
125 Correct 5 ms 1020 KB Output is correct
126 Correct 5 ms 376 KB Output is correct