제출 #1250376

#제출 시각아이디문제언어결과실행 시간메모리
1250376guymmk3개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
#include "triples.h"
using namespace std;
vector<int> v;
map<array<int,3>,int>mp;
int is_triple(vector<int>g){
  sort(g.begin(),g.end());
  if(mp[g]||(g[0]==g[1]&&g[0]!=g[2]&&g[1]!=g[1]))return 0;
  mp[g]++;
  vector<int>a,b;
  a={g[1]-g[0],g[2]-g[0],g[2]-g[1]};
  b={v[g[0]],v[g[1]],v[g[2]]};
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  return (int)(a==b);
}
long long count_triples(vector<int> hsh) {
  mp.clear();
    v=hsh;
    int ans=0;
    int n=v.size();
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
              ans+=is_triple({i,j,i+v[i]});
              ans+=is_triple({i,j,j+v[i]});
              ans+=is_triple({i,j,i+v[j]});
              ans+=is_triple({i,j,j+v[j]});
              ans+=is_triple({i,j,i-v[i]});
              ans+=is_triple({i,j,j-v[i]});
              ans+=is_triple({i,j,i-v[j]});
              ans+=is_triple({i,j,j-v[j]});
             
            
        }
    }return ans;
}

vector<int> construct_range(int M, int K) {
  return {1, 1, 1};
}

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

triples.cpp: In function 'int is_triple(std::vector<int>)':
triples.cpp:10:8: error: no match for 'operator[]' (operand types are 'std::map<std::array<int, 3>, int>' and 'std::vector<int>')
   10 |   if(mp[g]||(g[0]==g[1]&&g[0]!=g[2]&&g[1]!=g[1]))return 0;
      |        ^
In file included from /usr/include/c++/11/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from triples.cpp:3:
/usr/include/c++/11/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::array<int, 3>; _Tp = int; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::array<int, 3>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const std::array<int, 3>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::array<int, 3>; _Tp = int; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::array<int, 3>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::map<std::array<int, 3>, int>::key_type&&' {aka 'std::array<int, 3>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
triples.cpp:11:5: error: no match for 'operator[]' (operand types are 'std::map<std::array<int, 3>, int>' and 'std::vector<int>')
   11 |   mp[g]++;
      |     ^
In file included from /usr/include/c++/11/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from triples.cpp:3:
/usr/include/c++/11/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::array<int, 3>; _Tp = int; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::array<int, 3>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const key_type&' {aka 'const std::array<int, 3>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::array<int, 3>; _Tp = int; _Compare = std::less<std::array<int, 3> >; _Alloc = std::allocator<std::pair<const std::array<int, 3>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::array<int, 3>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::map<std::array<int, 3>, int>::key_type&&' {aka 'std::array<int, 3>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~