제출 #647396

#제출 시각아이디문제언어결과실행 시간메모리
647396tvladm2009Genetics (BOI18_genetics)C++14
100 / 100
438 ms40372 KiB
#include <bits/stdc++.h> using ll = long long; int const nmax = 4100; int const sigma = 257; int const modulo = 1e9 + 7; std::string s[1 + nmax]; int r[1 + nmax], code[sigma], cost[1 + nmax][sigma]; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); srand(time(0)); int n, m, k; std::cin >> n >> m >> k; code['A'] = 0; code['G'] = 1; code['C'] = 2; code['T'] = 3; ll sum = 0; for(int i = 1;i <= n; i++) { std::cin >> s[i]; r[i] = rand() % modulo; sum += r[i]; for(int j = 0;j < m; j++) { cost[j][code[s[i][j]]] += r[i]; cost[j][code[s[i][j]]] %= modulo; } } for(int i = 1;i <= n; i++) { ll aux = (sum - r[i] + modulo) % modulo; aux *= k; aux %= modulo; for(int j = 0;j < m; j++) { for(int c = 0;c < 4; c++) { if(c == code[s[i][j]]) continue; aux -= cost[j][c]; if(aux < 0) aux += modulo; } } if(aux == 0) { std::cout << i << "\n"; return 0; } } return 0; }

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

genetics.cpp: In function 'int main()':
genetics.cpp:27:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   27 |       cost[j][code[s[i][j]]] += r[i];
      |                           ^
genetics.cpp:28:27: warning: array subscript has type 'char' [-Wchar-subscripts]
   28 |       cost[j][code[s[i][j]]] %= modulo;
      |                           ^
genetics.cpp:38:29: warning: array subscript has type 'char' [-Wchar-subscripts]
   38 |         if(c == code[s[i][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...