이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[y+1][s][e] - sum[x][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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |