제출 #416104

#제출 시각아이디문제언어결과실행 시간메모리
416104pauloamedBitaro’s Party (JOI18_bitaro)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define MAXN 100010 #define ppiii pair<pair<int,int>,int> int n; vector<int> v[MAXN]; vector<int> rv[MAXN]; int fullSolution(int x, vector<bool> &on){ vector<int> pd(n, -1); pd[x] = 0; for(int i = x; i >= 0; --i){ if(pd[i] != -1){ for(auto y : rv[i]){ pd[y] = max(pd[y], pd[i] + 1); } } } int ans = -1; for(int i = 0; i <= x; ++i){ // cout << pd[i] << endl; if(on[i]) ans = max(ans, pd[i]); } return ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int m, q; cin >> n >> m >> q; for(int i = 0; i < m; ++i){ int a, b; cin >> a >> b; a--, b--; if(a > b) swap(a, b); v[a].push_back(b); rv[b].push_back(a); } int block = sqrt(n) + 3; // cout << block << endl; vector<vector<pair<int,int>>> bestDists(n); for(int i = 0; i < n; ++i){ vector<int> currPointers(rv[i].size()); vector<bool> occour(n); priority_queue<ppiii, vector<ppiii>, less<ppiii>> pq; for(int j = 0; j < rv[i].size(); ++j){ pq.push(make_pair(bestDists[rv[i][j]].front(), j)); } while(pq.size() && bestDists[i].size() < block){ auto x = pq.top(); int j = x.second; int id = x.first.second; pq.pop(); if(++currPointers[j] < bestDists[rv[i][j]].size()){ pq.push(make_pair(bestDists[rv[i][j]][currPointers[j], j)); } if(!occour[id]){ occour[id] = true; bestDists[i].push_back(x.first); } } for(auto &x : bestDists[i]) x.first++; bestDists[i].push_back({0, i}); } vector<bool> on(n, true); while(q--){ int x, y; cin >> x >> y; x--; vector<int> currOff; while(y--){ int z; cin >> z; z--; on[z] = false; currOff.push_back(z); } int ans = -1; for(auto z : bestDists[x]){ if(on[z.second]){ ans = z.first; break; } } if(ans == -1) ans = fullSolution(x, on); cout << ans << "\n"; for(auto z : currOff) on[z] = true; } }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int j = 0; j < rv[i].size(); ++j){
      |                    ~~^~~~~~~~~~~~~~
bitaro.cpp:57:44: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |     while(pq.size() && bestDists[i].size() < block){
      |                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~
bitaro.cpp:63:28: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |       if(++currPointers[j] < bestDists[rv[i][j]].size()){
      |          ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:64:65: error: expected ']' before ')' token
   64 |         pq.push(make_pair(bestDists[rv[i][j]][currPointers[j], j));
      |                                                                 ^
      |                                                                 ]
bitaro.cpp:64:65: error: no matching function for call to 'make_pair(__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type&)'
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 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 bitaro.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: candidate: 'template<class _T1, class _T2> constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&)'
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
/usr/include/c++/10/bits/stl_pair.h:567:5: note:   template argument deduction/substitution failed:
bitaro.cpp:64:65: note:   candidate expects 2 arguments, 1 provided
   64 |         pq.push(make_pair(bestDists[rv[i][j]][currPointers[j], j));
      |                                                                 ^