제출 #731715

#제출 시각아이디문제언어결과실행 시간메모리
731715Dipto_DebdipDNA 돌연변이 (IOI21_dna)C++17
0 / 100
23 ms5708 KiB
#include "dna.h" #include <bits/stdc++.h> #define ll long long int using namespace std; string aa, bb; void init(std::string a, std::string b) { aa = a, bb = b; } int get_distance(int x, int y) { string a, b; for (ll i = x; i <= y; i++) a += aa[i]; for (ll i = x; i <= y; i++) b += bb[i]; if (x == y) { if (a != b) return -1; } else if (y - x == 1) { string rev = a; if (a == b) return 0; reverse(rev.begin(), rev.end()); if (rev == b) return 1; else return -1; } else { if (a == b) return 0; else { if (a[0] == b[0]) { string rem1, rem2; rem1 += a[1]; rem1 += a[2]; rem2 += b[1]; rem2 += b[2]; reverse(rem1.begin(), rem2.begin()); if (rem1 == rem2) return 1; else return -1; } else if (a[1] == b[1]) { string rem1, rem2; rem1 += a[0]; rem1 += a[2]; rem2 += b[0]; rem2 += b[2]; reverse(rem1.begin(), rem2.begin()); if (rem1 == rem2) return 1; else return -1; } else if (a[2] == b[2]) { string rem1, rem2; rem1 += a[0]; rem1 += a[1]; rem2 += b[0]; rem2 += b[1]; reverse(rem1.begin(), rem2.begin()); if (rem1 == rem2) return 1; else return -1; } else { vector<char> one, two; for (char ch : a) one.push_back(ch); for (char ch : b) two.push_back(ch); sort(one.begin(), one.end()); sort(two.begin(), two.end()); if (one == two) return 2; else return -1; } } } }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:10:12: warning: control reaches end of non-void function [-Wreturn-type]
   10 |     string a, b;
      |            ^
#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...