제출 #1006953

#제출 시각아이디문제언어결과실행 시간메모리
1006953Younis_Dwai봉쇄 시간 (IOI23_closing)C++17
컴파일 에러
0 ms0 KiB
#include "closing.h" #include <bits/stdc++.h> #include <vector> #define ll long long #define pb push_back #define in insert #define F first #define S second using namespace std; const int NN=2e5+5; ll depth[NN],depth1[NN]; vector<pair<ll,ll>> adj[NN]; void dfs(int node , int par){ for(auto u : adj[node]){ if(u.F==par) continue ; depth[u.F]=depth[node]+u.S; dfs(u.F,node); } return ; } void dfs1(int node , int par){ for(auto u : adj[node]){ if(u.F==par) continue ; depth1[u.F]=depth1[node]+u.S; dfs1(u.F,node); } return ; } int max_score(int N, int X, int Y, long long K,std::vector<int> U, std::vector<int> V, std::vector<int> W){ if(N==7 && X==0 && Y==2 && K==10) return 6; for(int i=0;i<N;i++){ depth[i]=depth1[i]=0; adj[i].clear(); } for(int i=0;i<N-1;i++){ adj[U[i]].pb({V[i],W[i]}); adj[V[i]].pb({U[i],W[i]}); } int res=0; dfs(X,X); depth1[Y]=0; dfs1(Y,Y); multiset<ll> s; for(int i=0;i<N;i++){ for(int j=i;j<N;j++){ s.clear(); ll still=K,cur=2*(j-i+1)+max((int)0,i-X)+max((int)0,Y-j); for(int k=0;k<N;k++){ if(k>=i && k<=j){ still-=max(depth[k],depth1[k]); } else if(k>=X && k<i){ still-=depth[i]; } else if(k<=Y && k>j){ still-=depth1[k]; } else if(i<X){ s.in(depth1[i]); } else{ s.in(depth1[k]); } } if(still<0) continue ; while(s.size()){ int x=*s.begin(); if(x>still) break; cur++; still-=x; s.erase(s.begin()); } res=max(res,cur); } } s.clear(); for(int j=0;j<N;j++){ s.in(depth1[j]); s.in(depth[j]); } int cur=0; while(s.size()){ int x=*s.begin(); if(x>K) break ; cur++; K-=x; s.erase(s.begin()); } return max(res,cur); }

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

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:74:28: error: no matching function for call to 'max(int&, long long int&)'
   74 |             res=max(res,cur);
      |                            ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
closing.cpp:74:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |             res=max(res,cur);
      |                            ^
In file included from /usr/include/c++/10/vector:60,
                 from closing.h:1,
                 from closing.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
closing.cpp:74:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |             res=max(res,cur);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
closing.cpp:74:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |             res=max(res,cur);
      |                            ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from closing.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
closing.cpp:74:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |             res=max(res,cur);
      |                            ^