제출 #566889

#제출 시각아이디문제언어결과실행 시간메모리
566889pawnedDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; void init(std::string a, std::string b) { N = n; K = q; string a, b; cin>>a>>b; int type1[N]; int type2[N]; for (int i = 0; i < N; i++) { if (a[i] == 'A') type1[i] = 0; else if (a[i] == 'C') type1[i] = 1; else type1[i] = 2; if (b[i] == 'A') type2[i] = 0; else if (b[i] == 'C') type2[i] = 1; else type2[i] = 2; } int counts1[N + 1][3]; int counts2[N + 1][3]; for (int i = 0; i < 3; i++) { counts1[0][i] = 0; counts2[0][i] = 0; } for (int i = 1; i <= N; i++) { for (int j = 0; j < 3; j++) { counts1[i][j] = counts1[i - 1][j]; counts2[i][j] = counts2[i - 1][j]; } counts1[i][type1[i - 1]]++; counts2[i][type2[i - 1]]++; } /* cout<<"counts1: "<<endl; for (int i = 0; i < 3; i++) { for (int j = 0; j <= N; j++) { cout<<counts1[j][i]<<" "; } cout<<endl; } cout<<endl; */ int pfs[N + 1][3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { pfs[0][i][j] = 0; } } for (int i = 1; i <= N; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { pfs[i][j][k] = pfs[i - 1][j][k]; } } pfs[i][type1[i - 1]][type2[i - 1]]++; } } int get_distance(int x, int y) { int l, r; l = x; r = y; bool works = true; for (int j = 0; j < 3; j++) { if ((counts1[r + 1][j] - counts1[l][j]) != (counts2[r + 1][j] - counts2[l][j])) works = false; } if (!works) { cout<<-1<<endl; return 0; } int vals[3][3]; for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { vals[j][k] = pfs[r + 1][j][k] - pfs[l][j][k]; } } int total = vals[0][0] + vals[1][1] + vals[1][2]; int x = min(vals[0][1], vals[1][0]); total += x; vals[0][1] -= x; vals[1][0] -= x; int y = min(vals[0][2], vals[2][0]); total += y; vals[0][2] -= y; vals[2][0] -= y; int z = min(vals[1][2], vals[2][1]); total += z; vals[1][2] -= z; vals[2][1] -= z; total += 2 * max(vals[0][1], vals[1][0]); cout<<total<<endl; return 0; }

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

dna.cpp: In function 'void init(std::string, std::string)':
dna.cpp:14:2: error: 'N' was not declared in this scope
   14 |  N = n;
      |  ^
dna.cpp:14:6: error: 'n' was not declared in this scope
   14 |  N = n;
      |      ^
dna.cpp:15:2: error: 'K' was not declared in this scope
   15 |  K = q;
      |  ^
dna.cpp:15:6: error: 'q' was not declared in this scope
   15 |  K = q;
      |      ^
dna.cpp:16:9: error: declaration of 'std::string a' shadows a parameter
   16 |  string a, b;
      |         ^
dna.cpp:13:23: note: 'std::string a' previously declared here
   13 | void init(std::string a, std::string b) {
      |           ~~~~~~~~~~~~^
dna.cpp:16:12: error: declaration of 'std::string b' shadows a parameter
   16 |  string a, b;
      |            ^
dna.cpp:13:38: note: 'std::string b' previously declared here
   13 | void init(std::string a, std::string b) {
      |                          ~~~~~~~~~~~~^
dna.cpp:22:4: error: 'type1' was not declared in this scope
   22 |    type1[i] = 0;
      |    ^~~~~
dna.cpp:24:4: error: 'type1' was not declared in this scope
   24 |    type1[i] = 1;
      |    ^~~~~
dna.cpp:26:4: error: 'type1' was not declared in this scope
   26 |    type1[i] = 2;
      |    ^~~~~
dna.cpp:28:4: error: 'type2' was not declared in this scope
   28 |    type2[i] = 0;
      |    ^~~~~
dna.cpp:30:4: error: 'type2' was not declared in this scope
   30 |    type2[i] = 1;
      |    ^~~~~
dna.cpp:32:4: error: 'type2' was not declared in this scope
   32 |    type2[i] = 2;
      |    ^~~~~
dna.cpp:37:3: error: 'counts1' was not declared in this scope
   37 |   counts1[0][i] = 0;
      |   ^~~~~~~
dna.cpp:38:3: error: 'counts2' was not declared in this scope
   38 |   counts2[0][i] = 0;
      |   ^~~~~~~
dna.cpp:42:4: error: 'counts1' was not declared in this scope
   42 |    counts1[i][j] = counts1[i - 1][j];
      |    ^~~~~~~
dna.cpp:43:4: error: 'counts2' was not declared in this scope
   43 |    counts2[i][j] = counts2[i - 1][j];
      |    ^~~~~~~
dna.cpp:45:3: error: 'counts1' was not declared in this scope
   45 |   counts1[i][type1[i - 1]]++;
      |   ^~~~~~~
dna.cpp:45:14: error: 'type1' was not declared in this scope
   45 |   counts1[i][type1[i - 1]]++;
      |              ^~~~~
dna.cpp:46:3: error: 'counts2' was not declared in this scope
   46 |   counts2[i][type2[i - 1]]++;
      |   ^~~~~~~
dna.cpp:46:14: error: 'type2' was not declared in this scope
   46 |   counts2[i][type2[i - 1]]++;
      |              ^~~~~
dna.cpp:61:4: error: 'pfs' was not declared in this scope; did you mean 'ffs'?
   61 |    pfs[0][i][j] = 0;
      |    ^~~
      |    ffs
dna.cpp:67:5: error: 'pfs' was not declared in this scope; did you mean 'ffs'?
   67 |     pfs[i][j][k] = pfs[i - 1][j][k];
      |     ^~~
      |     ffs
dna.cpp:70:3: error: 'pfs' was not declared in this scope; did you mean 'ffs'?
   70 |   pfs[i][type1[i - 1]][type2[i - 1]]++;
      |   ^~~
      |   ffs
dna.cpp:70:10: error: 'type1' was not declared in this scope
   70 |   pfs[i][type1[i - 1]][type2[i - 1]]++;
      |          ^~~~~
dna.cpp:70:24: error: 'type2' was not declared in this scope
   70 |   pfs[i][type1[i - 1]][type2[i - 1]]++;
      |                        ^~~~~
dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:80:8: error: 'counts1' was not declared in this scope
   80 |   if ((counts1[r + 1][j] - counts1[l][j]) != (counts2[r + 1][j] - counts2[l][j]))
      |        ^~~~~~~
dna.cpp:80:47: error: 'counts2' was not declared in this scope
   80 |   if ((counts1[r + 1][j] - counts1[l][j]) != (counts2[r + 1][j] - counts2[l][j]))
      |                                               ^~~~~~~
dna.cpp:90:17: error: 'pfs' was not declared in this scope; did you mean 'ffs'?
   90 |    vals[j][k] = pfs[r + 1][j][k] - pfs[l][j][k];
      |                 ^~~
      |                 ffs
dna.cpp:94:6: error: declaration of 'int x' shadows a parameter
   94 |  int x = min(vals[0][1], vals[1][0]);
      |      ^
dna.cpp:74:22: note: 'int x' previously declared here
   74 | int get_distance(int x, int y) {
      |                  ~~~~^
dna.cpp:98:6: error: declaration of 'int y' shadows a parameter
   98 |  int y = min(vals[0][2], vals[2][0]);
      |      ^
dna.cpp:74:29: note: 'int y' previously declared here
   74 | int get_distance(int x, int y) {
      |                         ~~~~^