제출 #1062435

#제출 시각아이디문제언어결과실행 시간메모리
1062435TheQuantiXDNA 돌연변이 (IOI21_dna)C++17
100 / 100
294 ms88280 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n, m, q, k, x, y, a, b, c; map<char, int> mpa[100001]; map<char, int> mpb[100001]; map< pair<char, char>, int > mp[100001]; void init(string a, string b) { for (int i = 0; i < a.size(); i++) { mp[i + 1] = mp[i]; mp[i + 1][{a[i], b[i]}]++; mpa[i + 1] = mpa[i]; mpb[i + 1] = mpb[i]; mpa[i + 1][a[i]]++; mpb[i + 1][b[i]]++; } } int get_distance(int x, int y) { for (auto i : {'A', 'T', 'C'}) { // cout << i << ' ' << mpa[y + 1][i] - mpa[x][i] << ' ' << mpb[y + 1][i] - mpb[x][i] << '\n'; if (mpa[y + 1][i] - mpa[x][i] != mpb[y + 1][i] - mpb[x][i]) { return -1; } } map< pair<char, char>, int > mp1; for (auto i : mp[y + 1]) { mp1[i.first] = i.second - mp[x][i.first]; } int ans = 0; ll e; e = min(mp1[{'A', 'T'}], mp1[{'T', 'A'}]); ans += e; mp1[{'A', 'T'}] -= e; mp1[{'T', 'A'}] -= e; e = min(mp1[{'A', 'C'}], mp1[{'C', 'A'}]); ans += e; mp1[{'A', 'C'}] -= e; mp1[{'C', 'A'}] -= e; e = min(mp1[{'C', 'T'}], mp1[{'T', 'C'}]); ans += e; mp1[{'C', 'T'}] -= e; mp1[{'T', 'C'}] -= e; e = min({mp1[{'A', 'T'}], mp1[{'T', 'C'}], mp1[{'C', 'A'}]}); ans += e * 2; mp1[{'A', 'T'}] -= e; mp1[{'T', 'C'}] -= e; mp1[{'C', 'A'}] -= e; e = min({mp1[{'T', 'A'}], mp1[{'C', 'T'}], mp1[{'A', 'C'}]}); ans += e * 2; mp1[{'T', 'A'}] -= e; mp1[{'C', 'T'}] -= e; mp1[{'A', 'C'}] -= e; return ans; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...