Submission #1074706

#TimeUsernameProblemLanguageResultExecution timeMemory
1074706vnm06Dungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; int N; vector<int> S, P, W, L; int vert[10][400005][10]; long long jmp[10][400005][10]; long long gran[10][400005][10]; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { N=n; S=s; P=p; W=w; L=l; int le=1, ri=5; for(int tree=0; tree<10; tree++) { for(int i=0; i<n; i++) { if(s[i]<le) { vert[tree][i][0]=w[i]; jmp[tree][i][0]=s[i]; gran[tree][i][0]=ri; } else if(s[i]>ri) { vert[tree][i][0]=l[i]; jmp[tree][i][0]=p[i]; gran[tree][i][0]=ri; } else { vert[tree][i][0]=l[i]; jmp[tree][i][0]=p[i]; gran[tree][i][0]=s[i]-1; } } for(int lvl=1; lvl<10; lvl++) { for(int i=0; i<n; i++) { vert[tree][i][lvl]=vert[tree][i][lvl-1]; jmp[tree][i][lvl]=jmp[tree][i][lvl-1]; gran[tree][i][lvl]=gran[tree][i][lvl-1]; for(int j=1; j<=5; j++) { int nv=vert[tree][i][lvl]; if(nv==n) break; vert[tree][i][lvl]=vert[tree][nv][lvl-1]; gran[tree][i][lvl]=min(gran[tree][i][lvl], max(0, gran[tree][nv][lvl-1]-jmp[tree][i][lvl])); if(gran[tree][i][lvl]<=0) break; jmp[tree][i][lvl]+=jmp[tree][nv][lvl-1]; } } } le*=6; ri=le*6-1; } return; } long long simulate(int x, int z) { int v=x; long long st=z; int tree=0, le=1, ri=5; while(v!=N) { while(tree<9 && st>ri) { le*=6; ri=le*6-1; tree++; } for(int lvl=9; lvl>=0; lvl--) { for(int j=5;; j--) { if(st<=gran[tree][v][lvl]) { st+=jmp[tree][v][lvl]; v=vert[tree][v][lvl]; if(v==N) break; } else break; } if(v==N) break; } if(v==N) break; if(st<S[v]) { st+=P[v]; v=L[v]; } else { st+=S[v]; v=W[v]; } } return st; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:56:95: error: no matching function for call to 'max(int, long long int)'
   56 |      gran[tree][i][lvl]=min(gran[tree][i][lvl], max(0, gran[tree][nv][lvl-1]-jmp[tree][i][lvl]));
      |                                                                                               ^
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: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:
dungeons.cpp:56:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   56 |      gran[tree][i][lvl]=min(gran[tree][i][lvl], max(0, gran[tree][nv][lvl-1]-jmp[tree][i][lvl]));
      |                                                                                               ^
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: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:
dungeons.cpp:56:95: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   56 |      gran[tree][i][lvl]=min(gran[tree][i][lvl], max(0, gran[tree][nv][lvl-1]-jmp[tree][i][lvl]));
      |                                                                                               ^
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: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:
dungeons.cpp:56:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |      gran[tree][i][lvl]=min(gran[tree][i][lvl], max(0, gran[tree][nv][lvl-1]-jmp[tree][i][lvl]));
      |                                                                                               ^
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: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:
dungeons.cpp:56:95: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   56 |      gran[tree][i][lvl]=min(gran[tree][i][lvl], max(0, gran[tree][nv][lvl-1]-jmp[tree][i][lvl]));
      |                                                                                               ^