제출 #712592

#제출 시각아이디문제언어결과실행 시간메모리
712592danikoynovDNA 돌연변이 (IOI21_dna)C++17
0 / 100
31 ms2364 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 ++)
    {
        int j = i;
        while(j < s1.size() && s1[j] != t1[i])
            j ++;
        if (j == s1.size())
            return -1;
        for (int k = j; k > i; k --)
            swap(s1[k], s1[k - 1]);
        ans = ans + (j - i);
    }
    return ans;
}

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < t1.size(); i ++)
      |                     ~~^~~~~~~~~~~
dna.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         while(j < s1.size() && s1[j] != t1[i])
      |               ~~^~~~~~~~~~~
dna.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         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...