제출 #643739

#제출 시각아이디문제언어결과실행 시간메모리
643739rociohdzDNA 돌연변이 (IOI21_dna)C++17
56 / 100
37 ms6604 KiB
#include "dna.h" #include <cstdio> #include <cassert> #include <string> #include <vector> #include<bits/stdc++.h> #define pb push_back using namespace std; vector<char>s1,s2; vector<int>ta,tb,ta1,tb1,tc,tc1,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); tc.resize(a.size()+1,0); tc1.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 ); tc[0] = ((s1[0] == 'C') ? 1 : 0 ); tc1[0] = ((s2[0] == 'C') ? 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 ); tc[i] = tc[i - 1] + ((s1[i] == 'C') ? 1 : 0 ); tc1[i] = tc1[i - 1] + ((s2[i] == 'C') ? 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,c1,c2,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 ); c1 = tc[y] - (( (x - 1) >= 0 ) ? tc[x - 1] : 0 ); c2 = tc1[y] - (( (x - 1) >= 0 ) ? tc1[x - 1] : 0 ); d = t[y] - (( (x - 1) >= 0 ) ? t[x - 1] : 0 ); return ((a1 != a2 or b1 != b2 or c1 != c2) ? -1 : ( (d & 1) ? d / 2 + 1 : d / 2 )); }

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

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