제출 #484613

#제출 시각아이디문제언어결과실행 시간메모리
484613MrDebooDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" using namespace std; string a,b; void init(std::string A, std::string B) { a=A; b=B; } int get_distance(int l, int r) { vector<int>v(26); for(int i=l;i<=r;i++){ v[a[i]-'a']++; v[b[i]-'a']--; } for(int i=0;i<26;i++){ if(v[i]!=0)return -1; } if(l==r)return 0; if(l+1==r)return 1-(a[l]==b[l]); if(a[l]==b[l]&&a[l+1]==b[l+1])return 0; if(a[l]==b[l]||a[l+1]==b[l+1]||a[l+2]==b[l+2])return 1; return 2; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:10:2: error: 'vector' was not declared in this scope
   10 |  vector<int>v(26);
      |  ^~~~~~
dna.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include "dna.h"
  +++ |+#include <vector>
    2 | using namespace std;
dna.cpp:10:9: error: expected primary-expression before 'int'
   10 |  vector<int>v(26);
      |         ^~~
dna.cpp:12:3: error: 'v' was not declared in this scope
   12 |   v[a[i]-'a']++;
      |   ^
dna.cpp:16:6: error: 'v' was not declared in this scope
   16 |   if(v[i]!=0)return -1;
      |      ^