제출 #1009481

#제출 시각아이디문제언어결과실행 시간메모리
1009481somefjordDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; string as, bs; vector<int> balance1, balance1, misplacecount; void init(string a, string b) { as = a; bs = b; int n = a.length(); balance1.resize(n + 2, 0); balance2.resize(n + 2, 0); misplacecount.resize(n + 2, 0); for (int i = 1; i <= n; ++i) { balance1[i] = balance1[i - 1] + (as[i - 1] == 'A' ? 1 : -1); balance2[i] = balance2[i - 1] + (bs[i - 1] == 'A' ? 1 : -1); misplacecount[i] = misplacecount[i - 1] + (as[i - 1] == 'A' && as[i - 1] != bs[i - 1]); // printf("i : %d, %d %d %d\n", i, acount1[i], acount2[i], // misplacecount[i]); } } int get_distance(int x, int y) { if ((balance1[y] - balance2[x]) != (balance2[y] - balance2[x])) return -1; return misplacecount[y] - misplacecount[x]; }

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

dna.cpp:7:23: error: redefinition of 'std::vector<int> balance1'
    7 | vector<int> balance1, balance1, misplacecount;
      |                       ^~~~~~~~
dna.cpp:7:13: note: 'std::vector<int> balance1' previously declared here
    7 | vector<int> balance1, balance1, misplacecount;
      |             ^~~~~~~~
dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:15:3: error: 'balance2' was not declared in this scope; did you mean 'balance1'?
   15 |   balance2.resize(n + 2, 0);
      |   ^~~~~~~~
      |   balance1
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:29:22: error: 'balance2' was not declared in this scope; did you mean 'balance1'?
   29 |   if ((balance1[y] - balance2[x]) != (balance2[y] - balance2[x]))
      |                      ^~~~~~~~
      |                      balance1