제출 #712603

#제출 시각아이디문제언어결과실행 시간메모리
712603danikoynovDNA 돌연변이 (IOI21_dna)C++17
43 / 100
1585 ms2424 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;
        int j = i;
        while(j < s1.size() && (s1[j] != t1[i] || s1[j] == t1[j]))
            j ++;
            ///cout << i << " : " << j << endl;
        if (j == s1.size())
            return -1;

        swap(s1[i], s1[j]);
        ans ++;
    }
    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:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         while(j < s1.size() && (s1[j] != t1[i] || s1[j] == t1[j]))
      |               ~~^~~~~~~~~~~
dna.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if (j == s1.size())
      |             ~~^~~~~~~~~~~~
#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...