Submission #957838

#TimeUsernameProblemLanguageResultExecution timeMemory
957838hirayuu_ojMutating DNA (IOI21_dna)C++17
100 / 100
32 ms6424 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define rep2(i,a,b) for(int i=(a); i<(b); i++) #define all(x) x.begin(),x.end() using ll=long long; int cum[7][100010]; int get_type(char s,char t){ if(s=='A' and t=='T'){ return 0; } if(s=='T' and t=='A'){ return 1; } if(s=='A' and t=='C'){ return 2; } if(s=='C' and t=='A'){ return 3; } if(s=='T' and t=='C'){ return 4; } if(s=='C' and t=='T'){ return 5; } return 6; } void init(std::string a, std::string b) { rep(i,7){ cum[i][0]=0; } rep(i,a.size()){ rep(j,7){ cum[j][i+1]=cum[j][i]; } cum[get_type(a[i],b[i])][i+1]++; } } int get_distance(int x, int y) { int types[7]; rep(i,7){ types[i]=cum[i][y+1]-cum[i][x]; } if(types[0]+types[2]!=types[1]+types[3]){ return -1; } if(types[1]+types[4]!=types[0]+types[5]){ return -1; } int ans=0; rep(i,3){ int now=min(types[i*2],types[i*2+1]); types[i*2]-=now; types[i*2+1]-=now; ans+=now; } ans+=max(types[0],types[1])*2; return ans; } /* at ta ag ga tg gt */

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:4:32: 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 rep(i,n) for(int i=0; i<(n); i++)
      |                                ^
dna.cpp:35:2: note: in expansion of macro 'rep'
   35 |  rep(i,a.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...