제출 #497350

#제출 시각아이디문제언어결과실행 시간메모리
497350Maqsut_03DNA 돌연변이 (IOI21_dna)C++17
43 / 100
1528 ms4016 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; string a, b, a1, b1, a2; int n; map <char, int> arr; void init(string a0, string b0) { a = a0; b = b0; a1 = a; b1 = b; n = a.length(); } int get_distance(int x, int y) { int ans = 0; a = a1; b = b1; arr.clear(); for (int i = x; i <= y; i++) arr[a[i]]++, arr[b[i]]--; for (char i = 'A'; i <= 'Z'; i++) if (arr[i] != 0) return -1; if (a.size() > y-x+1) a = a.substr(x, y); if (b.size() > y-x+1) b = b.substr(x, y); // cout << a <<" " << b << " "; for (int i=0;i<=y-x;i++){ bool ok=0; for (int j=i+1;j<=y-x;j++){ if (a[i] == b[j] and b[i] != a[i] and a[j] == b[i]){ ok=1; ans++; swap(b[i], b[j]); // cout << 1; } } if (!ok){ for (int j=i+1;j<=y-x;j++){ if (a[i] == b[j] and b[i] != a[i]){ ans++; swap(b[i], b[j]); // cout << b <<" "; } } } } return ans; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:27:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     if (a.size() > y-x+1) a = a.substr(x, y);
      |         ~~~~~~~~~^~~~~~~
dna.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |     if (b.size() > y-x+1) b = b.substr(x, y);
      |         ~~~~~~~~~^~~~~~~
#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...