제출 #573071

#제출 시각아이디문제언어결과실행 시간메모리
573071Md_AbdullahDNA 돌연변이 (IOI21_dna)C++17
0 / 100
31 ms3764 KiB
#include "dna.h"
#include<bits/stdc++.h>
using namespace std;

string s,s2;
void init(std::string a, std::string b) {
    s = a;
    s2 = b;
}

int get_distance(int x, int y) {
	string temp,temp2;
	for(int i=x;i<=y;i++)
    {
        temp+=s[i];
        temp2+=s2[i];
    }
    int res = 0;
    for(int i=0;i<temp.size();i++)
    {
        if(temp[i]!=temp2[i])
        {
            for(int j=i+1;j<temp2.size();j++)
            {
                if(temp[j]==temp2[i])
                {
                    res++;
                    swap(temp[i],temp[j]);
                }
            }
        }
    }
    if(temp!=temp2)
        res = -1;
	return res;
}

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:19:18: 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<temp.size();i++)
      |                 ~^~~~~~~~~~~~
dna.cpp:23:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             for(int j=i+1;j<temp2.size();j++)
      |                           ~^~~~~~~~~~~~~
dna.cpp:33:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   33 |     if(temp!=temp2)
      |     ^~
dna.cpp:35:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |  return res;
      |  ^~~~~~
#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...