Submission #1009621

#TimeUsernameProblemLanguageResultExecution timeMemory
1009621induwara16Mutating DNA (IOI21_dna)C++17
0 / 100
1546 ms4432 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; typedef string str; typedef vector<int> vi; str a, b; void init(std::string a1, std::string b2) { a = a1; b = b2; } int get_distance(int x, int y) { str a1 = a.substr(x, y); multiset<char> a2(a1.begin(), a1.end()), b2(b.begin() + x, b.begin() + y + 1); str b1(b2.begin(), b2.end()); int n = a1.length(); int as = b1.find_last_of('A'), cs = b1.find_last_of('C'), ts = b1.find_last_of('T'); int ac, cc, tc; if (as == b1.npos) ac = 0; else ac = as + 1; if (cs == b1.npos) cc = 0; else cc = cs - ac + 1; if (ts == b1.npos) tc = 0; else if (cc == 0) tc = ts - ac + 1; else tc = ts - cs + 1; cout << ac << ',' << cc << ',' << tc << '\n'; if (!equal(a2.begin(), a2.end(), b2.begin())) return -1; if ((ac == n) || (cc == n) || (tc == n)) return 0; if ((ac == 0) || (cc == 0) || (tc == 0)) return 1; bool same = false; for (int i = 0; i < n; i++) { if (a1[i] == b1[i]) { same = true; break; } } return same ? 1 : 2; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:26:9: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
   26 |  if (as == b1.npos)
dna.cpp:31:9: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
   31 |  if (cs == b1.npos)
dna.cpp:36:9: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
   36 |  if (ts == b1.npos)
#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...