제출 #442371

#제출 시각아이디문제언어결과실행 시간메모리
442371nekiDNA 돌연변이 (IOI21_dna)C++17
0 / 100
54 ms10372 KiB
#include <bits/stdc++.h> #define ll long long #define loop(i, a, b) for(ll i=a;i<b;++i) #define pool(i, a, b) for(ll i=a-1;i>=b;--i) #define fore(i, a) for(auto&& i:a) #define fi first #define se second #define ps(a) push_back(a) #define pb(a) pop_back(a) #define eb(...) emplace_back(__VA_ARGS__) #define sc scanf #define vc vector #define lb lower_bound #define ub upper_bound #define all(a) a.begin(), a.end() #define llmax LLONG_MAX/2 #define llmin -LLONG_MAX/2 using namespace std; #define mn 400100 #define par pair<ll, ll> #define ld long double ll n; ll sum[mn][3][3]; void init(string a, string b){ n=a.size(); vc<char> temp={'A', 'T', 'C'}; loop(i, 1, n+1){ loop(x, 0, 3) loop(y, 0, 3) sum[i][x][y]=sum[i-1][x][y]; loop(x, 0, 3) if(a[i-1]==temp[x]) loop(y, 0, 3) if(b[i-1]==temp[y]) sum[i][x][y]++; } } int get_distance(int x, int y){ ll cur[3][3]; loop(s, 0, 3) loop(e, 0, 3) cur[s][e]=sum[x+1][s][e] - sum[y][s][e]; vc<ll> cnt(3, 0); loop(s, 0, 3) loop(e, 0, 3) cnt[s]+=cur[s][e], cnt[e]-=cur[s][e]; ll br=1;loop(i, 0, 3) if(cnt[i]) br=0; if(br==0) return -1; ll ans=0; loop(s, 0, 3) loop(e, 0, 3) if(s!=e){ ll te=min(cur[s][e], cur[e][s]); ans+=te; cur[s][e]-=te; cur[e][s]-=te; } ll mm=0; loop(s, 0, 3) loop(e, 0, 3) if(s!=e) mm=max(mm, cur[s][e]); ans+=2 * mm; return ans; }
#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...