Submission #712595

#TimeUsernameProblemLanguageResultExecution timeMemory
712595danikoynovDNA 돌연변이 (IOI21_dna)C++17
0 / 100
31 ms2372 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; if (i == j) continue; swap(s1[i], s1[j]); ans ++; } return ans; }

Compilation message (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())
      |             ~~^~~~~~~~~~~~
dna.cpp:24:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |         if (j == s1.size())
      |         ^~
dna.cpp:26:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   26 |             if (i == 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...