제출 #334296

#제출 시각아이디문제언어결과실행 시간메모리
334296nicholaskArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; int bit[200005]; void add(int x,int v){ for (int i=x; i<200005; i+=(i&-i)) bit[i]+=v; } int query(int x){ int ans=0; for (int i=x; i; i-=(i&-i)) ans+=bit[i]; return ans; } long long count_swaps(vector <int> s){ int n=(s.size()>>1),ans=0; vector <pair <int,int> > shs[100001]; vector <pair <int,int> > q; for (int i=0; i<n+n; i++) shs[abs(s[i])].push_back({s[i],i}); for (int i=1; i<100001; i++){ sort(shs[i].begin(),shs[i].end()); int m=(shs[i].size()>>1); for (int j=0; j<m; j++){ int ff=shs[i][j].second,ss=shs[i][j+m].second; if (ff>ss){ swap(ff,ss); ans++; } q.push_back(ff+1,ss+1); } } sort(q.begin(),q.end()); for (int i=1; i<=n+n; i++) add(i,1); for (auto&i:q){ ans+=query(i.second-1)-query(i.first); add(i.first,-1); add(i.second,-1); } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:27:25: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int, int)'
   27 |    q.push_back(ff+1,ss+1);
      |                         ^
In file included from /usr/include/c++/9/vector:67,
                 from shoes.h:5,
                 from shoes.cpp:1:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note:   candidate expects 1 argument, 2 provided