Submission #1141878

#TimeUsernameProblemLanguageResultExecution timeMemory
1141878jokerMutating DNA (IOI21_dna)C++17
Compilation error
0 ms0 KiB
#include "dna.h" using namespace std; string ast; string bst; void init(std::string a, std::string b) { ast = a; bst = b; } int get_distance(int x, int y) { string sl = ast.substr(x-1,y-x+1); string sr = bst.substr(x-1,y-x+1); string t1 = sl; string t2 = sr; sort(t1.begin(),t1.end()); sort(t2.begin(),t2.end()); if (t1 == t2) { int ans = 0; int i = 0; while (sl != sr) { if (sl[i] == sr[i]) { i++; } else { for (size_t j = i+1;j < y-x+1;j++){ if (sl[j] == sr[i]) { swap(sl[j],sl[i]); } } ans++; } } return ans; } return -1; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:16:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   16 |     sort(t1.begin(),t1.end());
      |     ^~~~
      |     short