Submission #1057428

#TimeUsernameProblemLanguageResultExecution timeMemory
1057428TrentMutating DNA (IOI21_dna)C++17
22 / 100
1574 ms4188 KiB
#include "dna.h" #include "bits/stdc++.h" using namespace std; #define forR(i, x) for(int i = 0; i < (x); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) typedef long long ll; typedef vector<int> vi; string a, b; void init(std::string a, std::string b) { ::a = a; ::b = b; } int id(char v) { return v == 'A' ? 0 : v == 'C' ? 1 : 2; } int get_distance(int x, int y) { vector<vi> cnt(3, vi(3, 0)); REP(i, x, y+1) { cnt[id(a[i])][id(b[i])]++; } int ab=min(cnt[0][1], cnt[1][0]), ac=min(cnt[0][2], cnt[2][0]), bc=min(cnt[1][2], cnt[2][1]); cnt[0][1]-=ab, cnt[1][0]-=ab; cnt[0][2]-=ac, cnt[2][0]-=ac; cnt[1][2]-=bc, cnt[2][1]-=bc; int abt=max(cnt[0][1], cnt[1][0]), act=max(cnt[0][2], cnt[2][0]), bct=max(cnt[1][2], cnt[2][1]); int ret = -1; if(abt == act && act == bct) { ret = ab + ac + bc + 2 * abt; } if(y - x <= 2) { int real = -1; string as=a.substr(x, y-x+1), bs=b.substr(x, y-x+1); if(as == bs) real = 0; forR(i, as.size()) forR(j, as.size()) { swap(as[i], as[j]); if(as == bs) real = real == -1 ? 1 : min(real, 1); forR(k, as.size()) forR(l, as.size()) { swap(as[k], as[l]); if(as == bs) real = real == -1 ? 2 : min(real, 2); swap(as[k], as[l]); } swap(as[i], as[j]); } assert(ret == real); } return ret; }

Compilation message (stderr)

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
dna.cpp:38:3: note: in expansion of macro 'forR'
   38 |   forR(i, as.size()) forR(j, as.size()) {
      |   ^~~~
dna.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
dna.cpp:38:22: note: in expansion of macro 'forR'
   38 |   forR(i, as.size()) forR(j, as.size()) {
      |                      ^~~~
dna.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
dna.cpp:41:4: note: in expansion of macro 'forR'
   41 |    forR(k, as.size()) forR(l, as.size()) {
      |    ^~~~
dna.cpp:4:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    4 | #define forR(i, x) for(int i = 0; i < (x); ++i)
      |                                     ^
dna.cpp:41:23: note: in expansion of macro 'forR'
   41 |    forR(k, as.size()) forR(l, as.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...