제출 #1001658

#제출 시각아이디문제언어결과실행 시간메모리
1001658vjudge1DNA 돌연변이 (IOI21_dna)C++17
43 / 100
1549 ms8536 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];

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] ;
        }
       // cout << mtch[A[i]]<<" s "<< mtch[B[i]]<<endl;
        how[0][i+1][mtch[A[i]]]++;
        how[1][i+1][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++){
       // cout << how[0][y+1][i]<<" "<<how[0][x][i]<<endl;
         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]){
           add++;
         //   cout << a[i]<< " " << mtch[a[i]]<<endl;
           if(mp[mtch[a[i]]]){
                sub++;
                mp[mtch[a[i]]]--;
           }
           else mp[mtch[b[i]]]++;
    
            
       }
         
    }
    //cout << add<<" "<<sub<< " "<< endl;
    return add-sub;
}

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     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...