Submission #1001908

#TimeUsernameProblemLanguageResultExecution timeMemory
1001908vjudge1Mutating DNA (IOI21_dna)C++17
43 / 100
1559 ms8548 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define f first #define s second #define pb push_back #define pf push_front #define pi pair<int,int> string a,b; const int MAX = 1e5+1; int n; ll how[2][MAX][3]; ll cnt[MAX][3]; map<char,int>mtch; void init(string A, string B){ a = A; b = B; mtch['A']=0; mtch['C']=1; mtch['T']=2; for(int i = 0; i <a.size(); i++){ for(int j = 0; j<3; j++){ how[0][i+1][j] = how[0][i][j] ; how[1][i+1][j] = how[1][i][j] ; // cnt[i+1][j] = cnt[i][j]; } // cout << mtch[A[i]]<<" s "<< mtch[B[i]]<<endl; how[0][i+1][mtch[A[i]]]++; how[1][i+1][mtch[B[i]]]++; /* if(A[i]!=B[i])[ cnt[i+2][mtch[B[i]]]++; }*/ } } int get_distance(int x, int y){ ll add = 0; ll sub = 0; ll mp[3]; memset(mp,0,sizeof(mp)); int vala,valb; for(int i =0; i < 3; i++){ vala = how[0][y+1][i]-how[0][x][i]; valb = how[1][y+1][i]-how[1][x][i]; // cout<< vala<<" " << valb << endl; if(vala!=valb) return -1; } for(int i = x; i<= y; i++){ if(a[i]!=b[i]){ if(mp[mtch[a[i]]]){ //sub++; mp[mtch[a[i]]]--; } else{ mp[mtch[b[i]]]++; add++; } } } //cout << add<<" "<<sub<< " "<< endl; return add; } /* int main(){ int n,q ; cin >> n >> q; string a,b; cin >> a >>b; init(a,b); int x,y; while(q--){ cin >> x >>y; cout << get_distance(x,y)<<endl; } } */

Compilation message (stderr)

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