Submission #1193152

#TimeUsernameProblemLanguageResultExecution timeMemory
1193152trvhungDNA 돌연변이 (IOI21_dna)C++20
100 / 100
26 ms8780 KiB
#include "dna.h" #include <bits/stdc++.h> // #include <ext/rope> // #include <ext/pb_ds/assoc_container.hpp> // using namespace __gnu_pbds; // using namespace __gnu_cxx; using namespace std; // #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> #define ll long long #define ull unsigned long long #define ld long double #define pb push_back #define bit(mask, i) ((mask >> i) & 1) #define el '\n' #define F first #define S second template <class X, class Y> bool maximize(X &x, const Y &y) { return (x < y ? x = y, 1 : 0); } template <class X, class Y> bool minimize(X &x, const Y &y) { return (x > y ? x = y, 1 : 0); } const int INF = 1e9; const ll LINF = 1e18; const int MOD = 1e9 + 7; const int MULTI = 0; const ld eps = 1e-9; const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; // R D L U const int ddx[4] = {-1, 1, 1, -1}, ddy[4] = {1, 1, -1, -1}; // UR DR DL UL const char cx[4] = {'R', 'D', 'L', 'U'}; const ll base = 31; const int nMOD = 2; const ll mods[] = {(ll)1e9 + 10777, (ll)1e9 + 19777, (ll)1e9 + 3, (ll)1e9 + 3777}; const int MAX = 1e5 + 5; const char ch[3] = {'A', 'C', 'T'}; int n, prefChar[2][3][MAX], prefPairs[3][3][MAX]; string s, t; void init(string a, string b) { n = (int) a.size(); s = ' ' + a; t = ' ' + b; for (int i = 1; i <= n; ++i) for (int j = 0; j < 3; ++j) { prefChar[0][j][i] = prefChar[0][j][i - 1] + (s[i] == ch[j]); prefChar[1][j][i] = prefChar[1][j][i - 1] + (t[i] == ch[j]); } for (int i = 1; i <= n; ++i) for (int j = 0; j < 3; ++j) for (int k = 0; k < 3; ++k) prefPairs[j][k][i] = prefPairs[j][k][i - 1] + (s[i] == ch[j] && t[i] == ch[k]); } int get_distance(int x, int y) { ++x; ++y; for (int j = 0; j < 3; ++j) if (prefChar[0][j][y] - prefChar[0][j][x - 1] != prefChar[1][j][y] - prefChar[1][j][x - 1]) return -1; int res = 0, rem = 0; for (int i = 0; i < 2; ++i) for (int j = i + 1; j < 3; ++j) { int cntIJ = prefPairs[i][j][y] - prefPairs[i][j][x - 1]; int cntJI = prefPairs[j][i][y] - prefPairs[j][i][x - 1]; res += min(cntIJ, cntJI); rem += max(cntIJ, cntJI) - min(cntIJ, cntJI); } res += 2 * (rem / 3); return res; }
#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...