제출 #437870

#제출 시각아이디문제언어결과실행 시간메모리
437870aggrovectorMutating DNA (IOI21_dna)C++17
컴파일 에러
0 ms0 KiB
#include "dna.h" #include <iostream> #include <bits/stdc++.h> int s[100005],ac[100005],ca[100005],at[100005],ta[100005],ct[100005],tc[100005],n,i,mac,mat,mct; void init(std::string a, std::string b) { n=a.length(); for (i=0;i<n;i++) { if (i==0) { ac[i]=0; ca[i]=0; at[i]=0; ta[i]=0; ct[i]=0; tc[i]=0; } else { ac[i]=ac[i-1]; ca[i]=ca[i-1]; at[i]=at[i-1]; ta[i]=ta[i-1]; ct[i]=ct[i-1]; tc[i]=tc[i-1]; } if (a[i]=='A') { if (b[i]=='C') { ac[i]++; } else if (b[i]=='T') { at[i]++; } } else if (a[i]=='C') { if (b[i]=='A') { ca[i]++; } else if (b[i]=='T') { ct[i]++; } } else if (a[i]=='T') { if (b[i]=='A') { ta[i]++; } else if (b[i]=='C') { tc[i]++; } } } } int get_distance(int x, int y) { if (ac[y]-ac[x-1]+at[y]-at[x-1]!=ca[y]-ca[x-1]+ta[y]-ta[x-1]) { return -1; } if (ca[y]-ca[x-1]+ct[y]-ct[x-1]!=ac[y]-ac[x-1]+tc[y]-tc[x-1]) { return -1; } if (ta[y]-ta[x-1]+tc[y]-tc[x-1]!=at[y]-at[x-1]+ct[y]-ct[x-1]) { return -1; } mac=min(ac[y]-ac[x-1],ca[y]-ca[x-1]); mat=min(at[y]-at[x-1],ta[y]-ta[x-1]); mct=min(ct[y]-ct[x-1],tc[y]-tc[x-1]); return mac+mat+mct+2*(max(ac[y]-ac[x-1],ca[y]-ca[x-1])-mac); }

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

dna.cpp: In function 'int get_distance(int, int)':
dna.cpp:63:6: error: 'min' was not declared in this scope; did you mean 'std::min'?
   63 |  mac=min(ac[y]-ac[x-1],ca[y]-ca[x-1]);
      |      ^~~
      |      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:3:
/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:66:24: error: 'max' was not declared in this scope; did you mean 'std::max'?
   66 |  return mac+mat+mct+2*(max(ac[y]-ac[x-1],ca[y]-ca[x-1])-mac);
      |                        ^~~
      |                        std::max
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:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~