제출 #955118

#제출 시각아이디문제언어결과실행 시간메모리
955118IUA_HasinDNA 돌연변이 (IOI21_dna)C++17
56 / 100
32 ms8532 KiB
#include <bits/stdc++.h> #define endl "\n" #define finp for(int i=0; i<n; i++) #define fknp for(int k=0; k<n; k++) #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define inpintn int n; cin>>n #define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];} #define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];} #define ll long long using namespace std; #include "dna.h" ll const N = 1e5+10; string aa, bb; ll arra[N], arrc[N], arrt[N]; ll brra[N], brrc[N], brrt[N]; ll diff[N]; void init(std::string a, std::string b) { aa = a; bb = b; ll siz = a.size(); for(int i=0; i<siz; i++){ if(a[i]=='A'){ arra[i+1] = arra[i]+1; arrc[i+1] = arrc[i]; arrt[i+1] = arrt[i]; } else if(a[i]=='C'){ arra[i+1] = arra[i]; arrc[i+1] = arrc[i]+1; arrt[i+1] = arrt[i]; } else { arra[i+1] = arra[i]; arrc[i+1] = arrc[i]; arrt[i+1] = arrt[i]+1; } if(b[i]=='A'){ brra[i+1] = brra[i]+1; brrc[i+1] = brrc[i]; brrt[i+1] = brrt[i]; } else if(b[i]=='C'){ brra[i+1] = brra[i]; brrc[i+1] = brrc[i]+1; brrt[i+1] = brrt[i]; } else { brra[i+1] = brra[i]; brrc[i+1] = brrc[i]; brrt[i+1] = brrt[i]+1; } } for(int i=0; i<siz; i++){ char p = aa[i]; char q = bb[i]; if(p!=q){ diff[i+1] = diff[i]+1; } else { diff[i+1] = diff[i]; } } } int get_distance(int x, int y) { x = x+1; y = y+1; // ll siz1 = aa.size(); // ll diff[siz1+1]; // diff[0] = 0; // for(int i=0; i<siz1; i++){ // char p = aa[i]; // char q = bb[i]; // if(p!=q){ // diff[i+1] = diff[i]+1; // } else { // diff[i+1] = diff[i]; // } // } ll xa = arra[y]-arra[x-1]; ll xc = arrc[y]-arrc[x-1]; ll xt = arrt[y]-arrt[x-1]; ll ya = brra[y]-brra[x-1]; ll yc = brrc[y]-brrc[x-1]; ll yt = brrt[y]-brrt[x-1]; ll d = diff[y]-diff[x-1]; if(y-x<=2){ if(xa==ya && xc==yc && xt==yt){ if(d==0){ return 0; } else if(d==2){ return 1; } else { return 2; } } else { return -1; } } else { if(xa==ya && xc==yc && xt==yt){ if(xa==0 || xc==0 || xt==0){ ll ans = d/2; return ans; } // else { // } } else { return -1; } } // if(xa==ya && xc==yc && xt==yt){ // ll ans = d/2; // return ans; // } else { // return -1; // } }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:126:1: warning: control reaches end of non-void function [-Wreturn-type]
  126 | }
      | ^
#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...