제출 #442791

#제출 시각아이디문제언어결과실행 시간메모리
442791baluteshihDNA 돌연변이 (IOI21_dna)C++17
35 / 100
50 ms6528 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define X first #define Y second #define ALL(v) v.begin(), v.end() #define pb push_back #define SZ(a) ((int)a.size()) int num[256]; int prea[3][100005], preb[3][100005], same[100005]; int get_sum(int *arr, int l, int r) { if (l == 0) return arr[r]; return arr[r] - arr[l - 1]; } void init(string a, string b) { int n = SZ(a); num['A'] = 0, num['T'] = 1, num['C'] = 2; for (int i = 0; i < n; ++i) { ++prea[num[a[i]]][i]; ++preb[num[b[i]]][i]; same[i] = (a[i] == b[i]); } for (int i = 1; i < n; ++i) { prea[0][i] += prea[0][i - 1]; prea[1][i] += prea[1][i - 1]; prea[2][i] += prea[2][i - 1]; preb[0][i] += preb[0][i - 1]; preb[1][i] += preb[1][i - 1]; preb[2][i] += preb[2][i - 1]; same[i] += same[i - 1]; } } int get_distance(int x, int y) { if (get_sum(prea[0], x, y) != get_sum(preb[0], x, y)) return -1; if (get_sum(prea[1], x, y) != get_sum(preb[1], x, y)) return -1; if (get_sum(prea[2], x, y) != get_sum(preb[2], x, y)) return -1; return (y - x + 1 - get_sum(same, x, y)) / 2; }

컴파일 시 표준 에러 (stderr) 메시지

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:26:24: warning: array subscript has type 'char' [-Wchar-subscripts]
   26 |         ++prea[num[a[i]]][i];
      |                        ^
dna.cpp:27:24: warning: array subscript has type 'char' [-Wchar-subscripts]
   27 |         ++preb[num[b[i]]][i];
      |                        ^
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:46:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   46 |     if (get_sum(prea[2], x, y) != get_sum(preb[2], x, y))
      |     ^~
dna.cpp:48:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   48 |  return (y - x + 1 - get_sum(same, x, y)) / 2;
      |  ^~~~~~
#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...