제출 #958175

#제출 시각아이디문제언어결과실행 시간메모리
958175irmuunDNA 돌연변이 (IOI21_dna)C++17
100 / 100
30 ms7320 KiB
#include<bits/stdc++.h> #include "dna.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() const int N=1e5+5; int sum[N][3][3]; int num(char c){ if(c=='A') return 0; if(c=='T') return 1; return 2; } void init(string a,string b){ for(int i=0;i<a.size();i++){ int x=num(a[i]),y=num(b[i]); for(int j=0;j<3;j++){ for(int k=0;k<3;k++){ sum[i+1][j][k]=sum[i][j][k]; } } sum[i+1][x][y]++; } } int get_distance(int x,int y){ int a[3][3],ans=0; y++; for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ a[i][j]=sum[y][i][j]-sum[x][i][j]; } } for(int i=0;i<3;i++){ for(int j=i+1;j<3;j++){ int mn=min(a[i][j],a[j][i]); ans+=mn; a[i][j]-=mn; a[j][i]-=mn; } } if(min({a[0][1],a[1][2],a[2][0]})!=max({a[0][1],a[1][2],a[2][0]})){ return -1; } if(min({a[0][2],a[2][1],a[1][0]})!=max({a[0][2],a[2][1],a[1][0]})){ return -1; } ans+=min({a[0][1],a[1][2],a[2][0]})*2; ans+=min({a[0][2],a[2][1],a[1][0]})*2; return ans; }

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

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