제출 #439335

#제출 시각아이디문제언어결과실행 시간메모리
439335fvogel499DNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int siz = 100010; int psA [3][siz]; int psB [3][siz]; int insteadOf [3][3][siz]; int conv(char c) { if (c == 'A') return 0; else if (c == 'T') return 1; else return 2; } void init(string a, string b) { for (int i = 0; i < a.size(); i++) { for (int j = 0; j < 3; j++) { psA[j][i] = 0; psB[j][i] = 0; for (int k = 0; k < 3; k++) { insteadOf[j][k][i] = 0; } } } for (int i = 0; i < a.size(); i++) { psA[conv(a[i])][i]++; psB[conv(b[i])][i]++; insteadOf[conv(a[i])][conv(b[i])][i]++; } for (int i = 1; i < a.size(); i++) { for (int j = 0; j < 3; j++) { psA[j][i] += psA[j][i-1]; psB[j][i] += psB[j][i-1]; for (int k = 0; k < 3; k++) { insteadOf[j][k][i] += insteadOf[j][k][i-1]; } } } } int get_distance(int x, int y) { for (int i = 0; i < 3; i++) { int aSum = psA[i][y]; int bSum = psB[i][y]; if (x > 0) { aSum -= psA[i][x-1]; bSum -= psB[i][x-1]; } if (aSum != bSum) { return -1; } } int ins [3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { ins[i][j] = insteadOf[i][j][y]; if (x > 0) ins[i][j] -= insteadOf[i][j][x-1]; } } int count = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i == j) continue; while (ins[i][j] > 0 and ins[j][i] > 0) { count++; ins[i][j]--; ins[j][i]--; } } } int cycleLeft = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cycleLeft = max(cycleLeft, ins[i][j]); } } count += 2*cycleLeft; return count; } // int main() { // string a, b; // cin >> a >> b; // init(a, b); // int q; // cin >> q; // for (int i = 0; i < q; i++) { // int x, y; // cin >> x >> y; // cout << get_distance(x, y) << endl; // } // int d = 0; // d++; // }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:20:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
dna.cpp:29:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
dna.cpp:34:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i = 1; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccW5Jeg3.o: in function `main':
grader.cpp:(.text.startup+0x39d): undefined reference to `get_distance(int, int)'
collect2: error: ld returned 1 exit status