Submission #522130

#TimeUsernameProblemLanguageResultExecution timeMemory
522130new_accMutating DNA (IOI21_dna)C++17
100 / 100
38 ms8004 KiB
#include<bits/stdc++.h> #define fi first #define se second #define rep(a, b) for(int a = 0; a < (b); a++) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e5+10; string a,b; int pref[N][10]; void ob(char a,char b,int i){ rep(j,10) pref[i][j]=(i==0?0:pref[i-1][j]); if(a=='A' and b=='C') pref[i][0]++; if(a=='A' and b=='T') pref[i][1]++; if(a=='C' and b=='T') pref[i][2]++; if(a=='C' and b=='A') pref[i][3]++; if(a=='T' and b=='A') pref[i][4]++; if(a=='T' and b=='C') pref[i][5]++; if(a=='T') pref[i][6]++; if(a=='C') pref[i][7]++; if(a=='A') pref[i][8]++; if(b=='T') pref[i][6]--; if(b=='C') pref[i][7]--; if(b=='A') pref[i][8]--; } void init(string t1,string t2){ a=t1,b=t2; rep(i,t1.size()) ob(t1[i],t2[i],i); } int get_distance(int x,int y){ if(pref[y][6]!=(x==0?0:pref[x-1][6]) or pref[y][7]!=(x==0?0:pref[x-1][7]) or pref[y][8]!=(x==0?0:pref[x-1][8])) return -1; int sum0=pref[y][0]-(x==0?0:pref[x-1][0]); int sum1=pref[y][1]-(x==0?0:pref[x-1][1]); int sum2=pref[y][2]-(x==0?0:pref[x-1][2]); int sum3=pref[y][3]-(x==0?0:pref[x-1][3]); int sum4=pref[y][4]-(x==0?0:pref[x-1][4]); int sum5=pref[y][5]-(x==0?0:pref[x-1][5]); return max(sum0,sum3)+max(sum1,sum4)+max(sum2,sum5)-max({abs(sum0-sum3),abs(sum1-sum4),abs(sum2-sum5)}); }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:4:36: 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(a, b) for(int a = 0; a < (b); a++)
      |                                    ^
dna.cpp:29:2: note: in expansion of macro 'rep'
   29 |  rep(i,t1.size()) ob(t1[i],t2[i],i);
      |  ^~~
#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...