Submission #1097688

#TimeUsernameProblemLanguageResultExecution timeMemory
1097688WarinchaiMutating DNA (IOI21_dna)C++17
56 / 100
25 ms8208 KiB
#include "dna.h" #include<bits/stdc++.h> using namespace std; long long vala[100005]; long long valb[100005]; long long same[100005]; int aA[100005]; int aC[100005]; int aT[100005]; int bA[100005]; int bC[100005]; int bT[100005]; long long md=1e9+7; void init(std::string a, std::string b) { long long ta=0,tb=0; for(int i=0;i<a.size();i++){ vala[i+1]=((vala[i]*26)%md+a[i]-'A')%md; valb[i+1]=((valb[i]*26)%md+b[i]-'A')%md; aA[i+1]=aA[i],aC[i+1]=aC[i],aT[i+1]=aT[i]; bA[i+1]=bA[i],bC[i+1]=bC[i],bT[i+1]=bT[i]; if(a[i]=='A')aA[i+1]++; else if(a[i]=='T')aT[i+1]++; else aC[i+1]++; if(b[i]=='A')bA[i+1]++; else if(b[i]=='T')bT[i+1]++; else bC[i+1]++; //cerr<<"info:"<<vala[i+1]<<" "<<valb[i+1]<<"\n"; same[i+1]=same[i]; if(a[i]==b[i])same[i+1]++; } } int get_distance(int x, int y) { x++,y++; //cerr<<x<<" "<<y<<" "<<"info:\n"; //cerr<<aA[y]-aA[x-1]<<" "<<aT[y]-aT[x-1]<<"\n"; //cerr<<bA[y]-bA[x-1]<<" "<<bT[y]-bT[x-1]<<"\n"; //cerr<<"\n"; if(aA[y]-aA[x-1]!=bA[y]-bA[x-1])return -1; if(aT[y]-aT[x-1]!=bT[y]-bT[x-1])return -1; if(aC[y]-aC[x-1]!=bC[y]-bC[x-1])return -1; int val=y-x+1-same[y]+same[x-1]; //cerr<<"ans:\n"; //cerr<<y<<"-"<<x-1<<"-"<<same[y]<<"+"<<same[x-1]<<"\n"; return (val+1)/2; }

Compilation message (stderr)

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
dna.cpp:15:15: warning: unused variable 'ta' [-Wunused-variable]
   15 |     long long ta=0,tb=0;
      |               ^~
dna.cpp:15:20: warning: unused variable 'tb' [-Wunused-variable]
   15 |     long long ta=0,tb=0;
      |                    ^~
#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...