제출 #716239

#제출 시각아이디문제언어결과실행 시간메모리
716239kidlinDNA 돌연변이 (IOI21_dna)C++17
71 / 100
1580 ms3828 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string s, t; void init(std::string a, std::string b) { s = a; t = b; } int get_distance(int x, int y) { string s1 = s.substr(x, y - x + 1); string t1 = t.substr(x, y - x + 1); int ans = 0; for (int i = 0; i < t1.size(); i ++) { if (s1[i] == t1[i]) continue; bool done = false; for (int j = i; j < t1.size(); j ++) { if (s1[j] == t1[i] && t1[j] == s1[i]) { swap(s1[j], s1[i]); ans ++; done = true; break; } } if (!done) { for (int j = i; j < t1.size(); j ++) { if (s1[j] == t1[i] && s1[j] != t1[j]) { swap(s1[j], s1[i]); ans ++; done = true; break; } } } ///cout << i << " : " << j << endl; if (!done) return -1; } return ans; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < t1.size(); i ++)
      |                     ~~^~~~~~~~~~~
dna.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int j = i; j < t1.size(); j ++)
      |                         ~~^~~~~~~~~~~
dna.cpp:41:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for (int j = i; j < t1.size(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...