제출 #506469

#제출 시각아이디문제언어결과실행 시간메모리
506469CasperWongDNA 돌연변이 (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include<bits/stdc++.h> long long n,q,x,y,ans,len,temp1,temp2,cnt[100100][5][5],freqa[5][100100],freqb[5][100100]; void init(std::string a, std::string b) { for(int i=0;i<n;i++){ if(i>0){ freqa[1][i]=freqa[1][i-1]; freqb[1][i]=freqb[1][i-1]; freqa[2][i]=freqa[2][i-1]; freqb[2][i]=freqb[2][i-1]; freqa[3][i]=freqa[3][i-1]; freqb[3][i]=freqb[3][i-1]; } if(a[i]=='A'){ freqa[1][i]++; }else if(a[i]=='T'){ freqa[2][i]++; }else{ freqa[3][i]++; } if(b[i]=='A'){ freqb[1][i]++; }else if(b[i]=='T'){ freqb[2][i]++; }else{ freqb[3][i]++; } for(int j=1;j<=3;j++){ for(int k=1;k<=3;k++){ if(i>0){ cnt[i][j][k]=cnt[i-1][j][k]; } } } if(a[i]=='A'){ if(b[i]=='A'){ cnt[i][1][1]++; }else if(b[i]=='T'){ cnt[i][1][2]++; }else{ cnt[i][1][3]++; } }else if(a[i]=='T'){ if(b[i]=='A'){ cnt[i][2][1]++; }else if(b[i]=='T'){ cnt[i][2][2]++; }else{ cnt[i][2][3]++; } }else{ if(b[i]=='A'){ cnt[i][3][1]++; }else if(b[i]=='T'){ cnt[i][3][2]++; }else{ cnt[i][3][3]++; } } } } int get_distance(int x, int y) { ans=0; temp1=0; temp2=0; if((freqa[1][y]-freqa[1][x-1]!=freqb[1][y]-freqb[1][x-1])||(freqa[2][y]-freqa[2][x-1]!=freqb[2][y]-freqb[2][x-1])||(freqa[3][y]-freqa[3][x-1]!=freqb[3][y]-freqb[3][x-1])){ cout<<"-1\n"; continue; } temp1=(cnt[y][1][2]-cnt[x-1][1][2])+(cnt[y][2][3]-cnt[x-1][2][3])+(cnt[y][3][1]-cnt[x-1][3][1]); temp2=(cnt[y][1][3]-cnt[x-1][1][3])+(cnt[y][3][2]-cnt[x-1][3][2])+(cnt[y][2][1]-cnt[x-1][2][1]); ans=abs(temp1-temp2)*2/3+min(temp1,temp2); cout<<ans<<endl; return 0; }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:68:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   68 |   cout<<"-1\n";
      |   ^~~~
      |   std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from dna.cpp:2:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
dna.cpp:69:3: error: continue statement not within a loop
   69 |   continue;
      |   ^~~~~~~~
dna.cpp:73:27: error: 'min' was not declared in this scope; did you mean 'std::min'?
   73 |  ans=abs(temp1-temp2)*2/3+min(temp1,temp2);
      |                           ^~~
      |                           std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dna.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
dna.cpp:74:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   74 |  cout<<ans<<endl;
      |  ^~~~
      |  std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from dna.cpp:2:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
dna.cpp:74:13: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   74 |  cout<<ans<<endl;
      |             ^~~~
      |             std::endl
In file included from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dna.cpp:2:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~