제출 #446985

#제출 시각아이디문제언어결과실행 시간메모리
446985georgerapeanuGenetics (BOI18_genetics)C++11
100 / 100
639 ms33608 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX = 4100; int n,m,k; string s[NMAX + 5]; int __map[256]; int main(){ cin >> n >> m >> k; for(int i = 1;i <= n;i++){ cin >> s[i]; s[i] = " " + s[i]; } vector<int> is_candidate(n + 1,true); vector<int> weight(n + 1,0); int cnt_cand = n; __map['A'] = 0; __map['C'] = 1; __map['G'] = 2; __map['T'] = 3; srand(time(NULL)); while(cnt_cand > 1){ vector<vector<long long> > cost(4,vector<long long>(m + 1,0)); long long total_weight = 0; for(int i = 1;i <= n;i++){ weight[i] = (rand() & 0x7fffffff); total_weight += weight[i]; for(int j = 1;j <= m;j++){ assert(s[i][j] == 'A' || s[i][j] == 'C' || s[i][j] == 'G' || s[i][j] == 'T'); cost[__map[s[i][j]]][j] += weight[i]; } } for(int i = 1;i <= n;i++){ if(is_candidate[i] == false){ continue; } long long current_weight = 0; for(int j = 1;j <= m;j++){ current_weight += total_weight - cost[__map[s[i][j]]][j]; } if(current_weight != k * (total_weight - weight[i])){ cnt_cand--; is_candidate[i] = false; } } } for(int i = 1;i <= n;i++){ if(is_candidate[i]){ cout << i << endl; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int main()':
genetics.cpp:41:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   41 |         cost[__map[s[i][j]]][j] += weight[i];
      |                           ^
genetics.cpp:53:60: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |         current_weight += total_weight - cost[__map[s[i][j]]][j];
      |                                                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...