제출 #975313

#제출 시각아이디문제언어결과실행 시간메모리
975313dostsMuseum (CEOI17_museum)C++17
컴파일 에러
0 ms0 KiB
//Dost SEFEROĞLU #pragma GCC optimize("O3,unroll-loops,Ofast") #include <bits/stdc++.h> using namespace std; //#define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define vi vector<int> const int N = 5e3+1,inf = 1e18,MOD = 998244353; int dp[N][2][N]; vector<pii> edges[N]; vi sz(N); int szs(int node,int p) { sz[node] = 1; for (auto it : edges[node]) if (it.ff != p) sz[node]+=szs(it.ff,node); return sz[node]; } int K; void compute(int node,int p) { int curmx = 1; for (auto it : edges[node]) { if (it.ff == p) continue; int u = it.ff,w = it.ss; compute(u,node); curmx+=sz[u]; for (int i=curmx;i>=2;i--) { for (int j=max(0ll,-curmx+sz[u]+i);j<=min(i,sz[u]);j++) { dp[node][0][i] = min(dp[node][0][i],dp[node][0][i-j] + dp[u][1][j]+ 2*w); dp[node][1][i] = min(dp[node][1][i],dp[node][1][i-j] + dp[u][1][j]+ 2*w); dp[node][0][i] = min(dp[node][0][i],dp[node][1][i-j] + dp[u][0][j] + w); } } } } void solve() { int n,x; cin >> n >> K >> x; for (int i=1;i<=n-1;i++) { int u,v,w; cin >> u >> v >> w; edges[u].push_back({v,w}); edges[v].push_back({u,w}); } for (int i=1;i<=n;i++) for(int j=0;j<2;j++) for (int k=2;k<=n;k++) dp[i][j][k] = inf; szs(x,x); compute(x,x); cout << dp[x][0][K] << endl; } signed main() { ios_base::sync_with_stdio(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }

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

museum.cpp:11:27: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   11 | const int N = 5e3+1,inf = 1e18,MOD = 998244353;
      |                           ^~~~
museum.cpp: In function 'void compute(int, int)':
museum.cpp:33:46: error: no matching function for call to 'max(long long int, int)'
   33 |             for (int j=max(0ll,-curmx+sz[u]+i);j<=min(i,sz[u]);j++) {
      |                                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from museum.cpp:3:
/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:
museum.cpp:33:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   33 |             for (int j=max(0ll,-curmx+sz[u]+i);j<=min(i,sz[u]);j++) {
      |                                              ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from museum.cpp:3:
/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:
museum.cpp:33:46: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   33 |             for (int j=max(0ll,-curmx+sz[u]+i);j<=min(i,sz[u]);j++) {
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from museum.cpp:3:
/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:
museum.cpp:33:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |             for (int j=max(0ll,-curmx+sz[u]+i);j<=min(i,sz[u]);j++) {
      |                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from museum.cpp:3:
/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:
museum.cpp:33:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |             for (int j=max(0ll,-curmx+sz[u]+i);j<=min(i,sz[u]);j++) {
      |                                              ^