제출 #1163445

#제출 시각아이디문제언어결과실행 시간메모리
1163445i271828Ekoeko (COCI21_ekoeko)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int MAX=100005; int N=4; char A[MAX]="soolnlsn"; map<char,vector<int>> index; vector<int> L; vector<int> R; int pos[MAX]; int dist[MAX]; int main(){ cin>>N; cin>>A; for (int i=0;i<2*N;i++){ index[A[i]].push_back(i); } for (auto pr:index){ char c=pr.first; int l=index[c].size(); for (int i=0;i<l/2;i++){ L.push_back(index[c][i]); R.push_back(index[c][l-1-i]); } } ll ans=0; for (int i=0;i<L.size();i++){ pos[L[i]]=i,pos[R[i]]=i; dist[i]=abs((R[i]-L[i]) - (N)); ans+=dist[i]; } cout<<ans/2; }

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

Main.cpp:8:23: error: 'std::map<char, std::vector<int> > index' redeclared as different kind of entity
    8 | map<char,vector<int>> index;
      |                       ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/11/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:48,
                 from Main.cpp:1:
/usr/include/strings.h:61:1: note: previous declaration 'const char* index(const char*, int)'
   61 | index (const char *__s, int __c) __THROW
      | ^~~~~
Main.cpp: In function 'int main()':
Main.cpp:18:22: error: invalid types '<unresolved overloaded function type>[char]' for array subscript
   18 |                 index[A[i]].push_back(i);
      |                      ^
Main.cpp:20:22: error: unable to deduce 'auto&&' from 'index'
   20 |         for (auto pr:index){
      |                      ^~~~~
Main.cpp:20:22: note:   couldn't deduce template parameter 'auto'
Main.cpp:22:28: error: invalid types '<unresolved overloaded function type>[char]' for array subscript
   22 |                 int l=index[c].size();
      |                            ^
Main.cpp:24:42: error: invalid types '<unresolved overloaded function type>[char]' for array subscript
   24 |                         L.push_back(index[c][i]);
      |                                          ^
Main.cpp:25:42: error: invalid types '<unresolved overloaded function type>[char]' for array subscript
   25 |                         R.push_back(index[c][l-1-i]);
      |                                          ^