이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>
// template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
// mt19937_64 rnd64(chrono::steady_clock::now().time_since_epoch().count());
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.141592653589793;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const int MAXN = 1e5 + 10;
int cnt[MAXN][7];
void init(string a, string b) {
for(int i = 0; i < a.size(); ++i) {
if(a[i] == 'A') cnt[i+1][0]++;
if(a[i] == 'T') cnt[i+1][1]++;
if(a[i] == 'C') cnt[i+1][2]++;
if(b[i] == 'A') cnt[i+1][3]++;
if(b[i] == 'T') cnt[i+1][4]++;
if(b[i] == 'C') cnt[i+1][5]++;
cnt[i+1][6] += (a[i] != b[i]);
for(int j = 0; j < 7; ++j) cnt[i + 1][j] += cnt[i][j];
}
}
int get_distance(int x, int y) {
++x;
++y;
for(int j = 0; j < 3; ++j) {
if(cnt[y][j] - cnt[x - 1][j] != cnt[y][j + 3] - cnt[x - 1][j + 3]) return -1;
}
return (cnt[y][6] - cnt[x - 1][6]) / 2;
}
// void solve() {
// init("ATACAT", "ACTATA");
// cout << get_distance(1, 3) << '\n';
// cout << get_distance(4, 5) << '\n';
// cout << get_distance(3, 5) << '\n';
// }
// int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// int CNT_TESTS = 1;
// // cin >> CNT_TESTS;
// for(int NUMCASE = 1; NUMCASE <= CNT_TESTS; ++NUMCASE) {
// solve();
// if(NUMCASE != CNT_TESTS) cout << '\n';
// }
// return 0;
// }
컴파일 시 표준 에러 (stderr) 메시지
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int i = 0; i < a.size(); ++i) {
| ~~^~~~~~~~~~
# | 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... |