# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
969282 |
2024-04-24T21:36:42 Z |
andro |
Mutating DNA (IOI21_dna) |
C++17 |
|
43 ms |
2388 KB |
#include <bits/stdc++.h>
#include "dna.h"
using namespace std;
string A, B;
void init(std::string a, std::string b) {
A = a;
B = b;
}
int get_distance(int x, int y) {
map<char,int> M, M1;
for(int i = x; i <= y; i++) {
M[A[i]] += 1;
M1[B[i]] += 1;
}
if(M['A'] != M1['A'] || M['T'] != M1['T'] || M['C'] != M1['C']) {
return - 1;
}
int ans = 0;
for(int i = x; i <= y; i++) {
if(A[i] == B[i]) {
continue;
}
int ok = 0;
for(int j = i + 1; j <= y; j++) {
if(A[i] == B[j] && A[j] == B[i]) {
swap(A[i], A[j]);
ok = 1;
break;
}
}
ans += 1;
if(! ok) {
for(int j = i + 1; j <= y; j++) {
if(B[i] == A[j]) {
swap(A[i], A[j]);
break;
}
}
}
}
return ans;
}
/*
int main() {
init("ATACAT", "ACTATA");
cout << get_distance(0, 5);
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
43 ms |
2388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
43 ms |
2388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |