제출 #738600

#제출 시각아이디문제언어결과실행 시간메모리
738600ToxtaqDNA 돌연변이 (IOI21_dna)C++17
43 / 100
1570 ms6072 KiB
#include<bits/stdc++.h> using namespace std; string a, b; vector<int>prefA, prefT, prefC; vector<int>pref2A, pref2T, pref2C; void init(string s1, string s2){ a = s1; b = s2; prefA.resize(s1.size() + 1); prefT.resize(s1.size() + 1); prefC.resize(s1.size() + 1); pref2A.resize(s1.size() + 1); pref2T.resize(s1.size() + 1); pref2C.resize(s1.size() + 1); for(int i = 0;i < s1.size();++i){ prefA[i + 1] = prefA[i] + (s1[i] == 'A'); prefT[i + 1] = prefT[i] + (s1[i] == 'T'); prefC[i + 1] = prefC[i] + (s1[i] == 'C'); pref2A[i + 1] = pref2A[i] + (s2[i] == 'A'); pref2T[i + 1] = pref2T[i] + (s2[i] == 'T'); pref2C[i + 1] = pref2C[i] + (s2[i] == 'C'); } } int get_distance(int x, int y){ map<string, int>mp; int res = 0, cnt = 0; if(prefA[y + 1] - prefA[x] != pref2A[y + 1] - pref2A[x])return -1; if(prefT[y + 1] - prefT[x] != pref2T[y + 1] - pref2T[x])return -1; if(prefC[y + 1] - prefC[x] != pref2C[y + 1] - pref2C[x])return -1; for(int i = x;i <= y;++i){ string tempo = ""; tempo += a[i]; tempo += b[i]; mp[tempo]++; } for(auto itr = mp.begin();itr != mp.end();++itr){ string s = itr->first; if(s[0] == s[1])continue; string d = s; reverse(d.begin(), d.end()); if(mp.count(d)){ // cout << s << " " << d << "\n"; int num = min(mp[d], mp[s]); res += num; mp[s] -= num; mp[d] -= num; // cout << mp[s] << " " << mp[d] << '\n'; } cnt += mp[s]; } if(cnt == 0)return res; return cnt - 1 + res; } //int main() //{ // string a, b; // cin >> a >> b; // init(a, b); // int q; // cin >> q; // while(q--){ // int l, r; // cin >> l >> r; // cout << get_distance(l, r) << '\n'; // } //}

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

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