제출 #464939

#제출 시각아이디문제언어결과실행 시간메모리
464939markoDNA 돌연변이 (IOI21_dna)C++17
56 / 100
642 ms104504 KiB
#include <bits/stdc++.h> using namespace std; vector<unordered_map<char, unordered_map<char, int>>> counts {}; vector<unordered_map<char, int>> absolute_counts {}; void init(string a, string b) { const int n = a.size(); counts.resize(n + 1); for (int i = 0; i < n; i++) { counts[i + 1] = counts[i]; counts[i + 1][a[i]][b[i]]++; } } int get_distance(int x, int y) { y++; int ans {}; auto cnts = counts[y]; int doubles {}; for (auto a : { 'A', 'C', 'T' }) for (auto b : { 'A', 'C', 'T' }) cnts[a][b] -= counts[x][a][b]; unordered_map<char, int> counts_a {}, counts_b {}; for (auto a : { 'A', 'C', 'T' }) { for (auto b : { 'A', 'C', 'T' }) { counts_a[a] += cnts[a][b]; counts_b[b] += cnts[a][b]; } } for (auto a : { 'A', 'C', 'T' }) { if (counts_a[a] != counts_b[a]) return -1; } for (auto a : { 'A', 'C', 'T' }) { for (auto b : { 'A', 'C', 'T' }) { if (b == a) continue; int take = min(cnts[a][b], cnts[b][a]); doubles += take; } } int triples {}; for (auto a : { 'A', 'C', 'T' }) { for (auto b : { 'A', 'C', 'T' }) { if (b == a) continue; for (auto c : { 'A', 'C', 'T' }) { if (c == b || c == a) continue; auto cnts_ab = cnts[a][b]; auto cnts_bc = cnts[b][c]; auto cnts_ca = cnts[c][a]; int take = min({ cnts[a][b], cnts[b][c], cnts[c][a] }); triples += take; } } } return (triples * 2) / 3 + doubles / 2; } // auto main() -> int // { // init("ATACAT", "ACTATA"); // cout << get_distance(1, 3) << endl; // cout << get_distance(4, 5) << endl; // cout << get_distance(3, 5) << endl; // }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:64:22: warning: unused variable 'cnts_ab' [-Wunused-variable]
   64 |                 auto cnts_ab = cnts[a][b];
      |                      ^~~~~~~
dna.cpp:65:22: warning: unused variable 'cnts_bc' [-Wunused-variable]
   65 |                 auto cnts_bc = cnts[b][c];
      |                      ^~~~~~~
dna.cpp:66:22: warning: unused variable 'cnts_ca' [-Wunused-variable]
   66 |                 auto cnts_ca = cnts[c][a];
      |                      ^~~~~~~
dna.cpp:23:9: warning: unused variable 'ans' [-Wunused-variable]
   23 |     int ans {};
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...