제출 #1001989

#제출 시각아이디문제언어결과실행 시간메모리
1001989vjudge1DNA 돌연변이 (IOI21_dna)C++17
56 / 100
28 ms9668 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 hold[MAX+1]; 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] ; // 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]]]++; } for(int i = 1; i <=a.size(); i++){ hold[i] =hold[i-1]; if(A[i-1]!=B[i-1]){ hold[i]++; } } } int get_distance(int x, int y){ // cout << y << " " << x << endl; // cout << hold[y+1] << " " << hold[x] << endl; ll add = hold[y+1]-hold[x] ; 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]; // cout<< vala<<" " << valb << endl; if(vala!=valb) return -1; } // if(add==0) return 0; 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; } } */

컴파일 시 표준 에러 (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++){
      |                    ~~^~~~~~~~~
dna.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     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...