Submission #999575

#TimeUsernameProblemLanguageResultExecution timeMemory
999575KasymKMutating DNA (IOI21_dna)C++17
43 / 100
1535 ms3312 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second string s3, s4; void init(string s, string s2){ s3 = s, s4 = s2; } int get_distance(int x, int y){ string a = "", b = ""; for(int i = x; i <= y; ++i) a += s3[i], b += s4[i]; // cout << a << " " << b << "\n"; int n = (int)a.size(); int sm = 0, sm2 = 0, sm3 = 0; for(int i = 0; i < n; ++i){ if(a[i] == 'A') sm++; if(b[i] == 'A') sm--; if(a[i] == 'C') sm2++; if(b[i] == 'C') sm2--; if(a[i] == 'T') sm3++; if(b[i] == 'T') sm3--; } if(sm or sm2 or sm3) return -1; int answer = 0; for(int i = 0; i < n; ++i){ if(a[i] == b[i]) continue; for(int j = i+1; j < n; ++j) if(a[j] == b[i] and a[i] == b[j] and a[i] != a[j]){ answer++; swap(a[i], a[j]); } if(a[i] == b[i]) continue; for(int j = i+1; j < n; ++j) if(a[j] == b[i] and a[i] != a[j]){ answer++; swap(a[i], a[j]); } } return answer; }
#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...