제출 #531623

#제출 시각아이디문제언어결과실행 시간메모리
53162379brue던전 (IOI21_dungeons)C++17
컴파일 에러
0 ms0 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n; ll arr[400002], power[400002]; int w[400002], l[400002]; ll nxt[25][60002][25]; /// 계속 지기만 했을 때의 최종 위치 ll sum[25][60002][25]; /// 계속 지기만 했을 때의 체력 변화 ll lim[25][60002][25]; /// 계속 지기만 할 수 있기 위한 최초 체력의 최댓값 ll bonus[400002]; void init(int N, vector<int> s, vector<int> p, vector<int> W, vector<int> L){ n = N; for(int i=0; i<n; i++) arr[i] = s[i]; for(int i=0; i<n; i++) power[i] = p[i], w[i]=W[i], l[i]=L[i]; l[n]=w[n]=n; arr[n] = 1e18, power[n]=0; for(int f=0; f<25; f++){ for(int i=0; i<=n; i++) nxt[f][i][0] = l[i], sum[f][i][0] = power[i], lim[f][i][0] = arr[i]-1; for(int d=1; d<25; d++){ for(int i=0; i<=n; i++){ nxt[f][i][d] = nxt[f][nxt[f][i][d-1]][d-1]; sum[f][i][d] = sum[f][i][d-1] + sum[f][nxt[f][i][d-1]][d-1]; sum[f][i][d-1] = min(sum[f][i][d-1], 1e18); lim[f][i][d] = min(lim[f][i][d-1], lim[f][nxt[f][i][d-1]][d-1] - sum[f][i][d-1]); } } } for(int i=n-1; i>=0; i--){ bonus[i] = arr[i] + bonus[w[i]]; } } ll simulate(int x, int _z){ ll z = _z; for(int f=0; f<25; f++){ if((1<<(f+1)) <= z) continue; /// 1. 계속 지다가 결국 탈출하기 ll minLeft = (1<<(f+1)) - z; ll pSum = 0; int tx = x, cnt1 = 0; for(int d=24; d>=0; d--){ if(pSum + sum[f][tx][d] < minLeft){ pSum += sum[f][tx][d]; tx = nxt[f][tx][d]; cnt1 += (1<<d); } } /// 2. 이겨서 탈출하기 int cnt2 = 0; tx = x; ll tz = z; for(int d=24; d>=0; d--){ if(lim[f][tx][d] >= tz){ tz += sum[f][tx][d]; tx = nxt[f][tx][d]; cnt2 += (1<<d); } } int cnt = min(cnt1, cnt2); for(int d=0; d<25; d++){ if((cnt>>d)&1){ z += sum[f][x][d]; x = nxt[f][x][d]; } } if(z >= arr[x]) z += arr[x], x = w[x]; else z += power[x], x = l[x]; } return z + bonus[x]; }

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:30:58: error: no matching function for call to 'min(ll&, double)'
   30 |                 sum[f][i][d-1] = min(sum[f][i][d-1], 1e18);
      |                                                          ^
In file included from /usr/include/c++/10/vector:60,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
dungeons.cpp:30:58: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   30 |                 sum[f][i][d-1] = min(sum[f][i][d-1], 1e18);
      |                                                          ^
In file included from /usr/include/c++/10/vector:60,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
dungeons.cpp:30:58: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   30 |                 sum[f][i][d-1] = min(sum[f][i][d-1], 1e18);
      |                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dungeons.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
dungeons.cpp:30:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |                 sum[f][i][d-1] = min(sum[f][i][d-1], 1e18);
      |                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from dungeons.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
dungeons.cpp:30:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |                 sum[f][i][d-1] = min(sum[f][i][d-1], 1e18);
      |                                                          ^