제출 #643730

#제출 시각아이디문제언어결과실행 시간메모리
643730rociohdzDNA 돌연변이 (IOI21_dna)C++17
35 / 100
46 ms5060 KiB
#include "dna.h"
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

vector<char>s1,s2;
vector<int>ta,tb,ta1,tb1,t;

void init(std::string a, std::string b) {
    ta.resize(a.size()+1,0);
    tb.resize(a.size()+1,0);
    ta1.resize(a.size()+1,0);
    tb1.resize(a.size()+1,0);
    t.resize(a.size()+1,0);

        s1.pb(a[0]);
        s2.pb(b[0]);
        ta[0] = ((s1[0] == 'A') ? 1 : 0 );
        ta1[0] = ((s2[0] == 'A') ? 1 : 0 );
        tb[0] = ((s1[0] == 'T') ? 1 : 0 );
        tb1[0] = ((s2[0] == 'T') ? 1 : 0 );
        ((s1[0] != s2[0]) ? t[0] = 1 : t[0] = 0 );

    for( int i = 1; i < a.size(); i++ ){
        s1.pb(a[i]);
        s2.pb(b[i]);
        ta[i] = ta[i - 1] + ((s1[i] == 'A') ? 1 : 0 );
        ta1[i] = ta1[i - 1] + ((s2[i] == 'A') ? 1 : 0 );
        tb[i] = tb[i - 1] + ((s1[i] == 'T') ? 1 : 0 );
        tb1[i] = tb1[i - 1] + ((s2[i] == 'T') ? 1 : 0 );
        ((s1[i] != s2[i]) ? t[i] = t[i - 1] + 1 : t[i] = t[i - 1] );
    }
}

int get_distance(int x, int y) {
   int a1,b1,a2,b2,d;
   a1 = ta[y] - (( (x - 1) >= 0 ) ? ta[x - 1] : 0 );
   a2 = ta1[y] - (( (x - 1) >= 0 ) ? ta1[x - 1] : 0 );
   b1 = tb[y] - (( (x - 1) >= 0 ) ? tb[x - 1] : 0 );
   b2 = tb1[y] - (( (x - 1) >= 0 ) ? tb1[x - 1] : 0 );
   d = t[y] - (( (x - 1) >= 0 ) ? t[x - 1] : 0 );

   return ((a1 != a2 or b1 != b2) ? -1 : d / 2 );
}

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:24:23: 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 = 1; 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...