이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dna.h"
#include <cstdio>
#include <cassert>
#include <string>
#include <vector>
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay
using t = tuple<int,int,int>;
vi pa[3], pb[3];
vi res;
void init(std::string a, std::string b) {
char cc[3] = {'A', 'C', 'T'};
int n = a.size();
for(int i = 0; i<3; i++){
pa[i].resize(n+1);
pb[i].resize(n+1);
}
res.resize(n+1);
for(int i = 0; i<n; i++){
for(int j = 0; j<3; j++){
pa[j][i+1] = pa[j][i] + (a[i] == cc[j]);
pb[j][i+1] = pb[j][i] + (b[i] == cc[j]);
}
res[i+1] = res[i]+
(a[i]=='A'&&b[i]!='A')+
(a[i]=='A'&&b[i]=='C')-
(a[i]=='C'&&b[i]=='A')+
(a[i]=='T'&&b[i]=='C');
}
}
int get_distance(int x, int y) {
for(int i = 0; i<3; i++){
if(pa[i][y+1]-pa[i][x]!=pb[i][y+1]-pb[i][x]) return -1;
}
return res[y+1]-res[x];
}
// int main() {
// #ifdef _WIN32
// freopen("input.in", "r", stdin);
// freopen("input.out", "w", stdout);
// #endif
// int n, q;
// cin>>n>>q;
// string a,b; cin>>a>>b;
// std::vector<int> x(q), y(q);
// for (int i = 0; i < q; i++) {
// cin>>x[i]>>y[i];
// }
// fclose(stdin);
// std::vector<int> results(q);
// init(a, b);
// for (int i = 0; i < q; i++) {
// results[i] = get_distance(x[i], y[i]);
// }
// for (int i = 0; i < q; i++) {
// cout<<results[i]<<'\n';
// }
// fclose(stdout);
// return 0;
// }
# | 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... |