Submission #1001948

#TimeUsernameProblemLanguageResultExecution timeMemory
1001948vjudge1Mutating DNA (IOI21_dna)C++17
0 / 100
22 ms4696 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+10;
int n;
 ll how[2][MAX][3];
ll cnt[MAX][3];
ll hold[MAX+1];
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]]]++;
        
        hold[i+1]=hold[i];*/
       if(A[i]!=B[i]){
            hold[i+1]++;
        }
    }
}


int get_distance(int x, int y){
    ll add = hold[y+1]-hold[x] ;
    string k = a.substr(x,y-x+1);
     string h= b.substr(x,y-x+1);
     sort(k.begin(),k.end());
     sort(h.begin(),h.end());
     if(h!=k){
        return -1;
     }
/*    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];
        if(vala!=valb) return -1;
    }
     */

    
  
    //cout << add<<" "<<sub<< " "<< endl;
    return (add+1)/2;
}



/*
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:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0; i <a.size(); 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...