제출 #729149

#제출 시각아이디문제언어결과실행 시간메모리
729149vjudge1DNA 돌연변이 (IOI21_dna)C++17
0 / 100
46 ms2616 KiB
#include "dna.h"
#include<bits/stdc++.h>
#define eb emplace_back

std::vector<char>A,B;

void init(std::string a, std::string b) {
    A.eb(' ');
    B.eb(' ');
    for(int i=0;i<a.size();++i){
        A.eb(a[i]);
        B.eb(b[i]);
    }
}

int get_distance(int x,int y){
    x++;
    y++;
    int noA,noT,noC;
    int res=0;
    std::map<char,int>M;
    M['A']=0;
    M['T']=0;
    M['C']=0;
    for(int i=x;i<=y;++i){
        if(A[i]!=B[i]){
            if(M[A[i]]!=0){
                M[A[i]]--;
            }
            else{
                res++;
                M[B[i]]++;
            }
        }
        if(A[i]=='A') noA++;
        else if(A[i]=='T') noT++;
        else noC++;
        if(B[i]=='A') noA--;
        else if(B[i]=='T') noT--;
        else noC--;
    }
    if(noA!=0 or noT!=0 or noC!=0) return -1;
    return res;
}

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:10:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0;i<a.size();++i){
      |                 ~^~~~~~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:19:17: warning: 'noC' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |     int noA,noT,noC;
      |                 ^~~
dna.cpp:19:13: warning: 'noT' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |     int noA,noT,noC;
      |             ^~~
dna.cpp:42:25: warning: 'noA' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |     if(noA!=0 or noT!=0 or noC!=0) return -1;
      |        ~~~~~~~~~~~~~~~~~^~~~~~~~~
#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...