Submission #437257

#TimeUsernameProblemLanguageResultExecution timeMemory
437257errorgornDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define fi first #define se second #define puf push_front #define pof pop_front #define pub push_back #define pob pop_back #define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);s<e?x++:x--) #define all(x) (x).begin(),(x).end() #define sz(x) (int) (x).size() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; ll win_s[50005]; ll lose_s[50005]; ll win_n[50005]; ll lose_n[50005]; struct edge{ int to; ll sum; int mx; //we cant have more strength or we will overshoot }; vector<ll> ds={0}; edge tkd[30][50005][30]; void init(int N, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { n=N; rep(x,0,n) win_s[x]=s[x]; rep(x,0,n) lose_s[x]=p[x]; rep(x,0,n) win_n[x]=w[x]; rep(x,0,n) lose_n[x]=l[x]; for (int x=1;x<4e7;x<<=1) ds.pub(x); //start of bueket sizes ds.pub(1e18); //for (auto &it:ds) cout<<it<<" "; cout<<endl; memset(tkd,-1,sizeof(tkd)); rep(i,0,sz(ds)-1){ rep(x,0,n){ if (win_s[x]<ds[i]){ //cfm will win tkd[i][x][0]=edge({win_n[x],win_s[x],(ll)1e9}); } else if (win_s[x]<ds[i+1]){ //by default, we lose, but if we win we must stop! tkd[i][x][0]=edge({lose_n[x],lose_s[x],win_s[x]}); } else{ //cfm will lose tkd[i][x][0]=edge({lose_n[x],lose_s[x],(ll)1e9}); } } rep(y,0,29){ rep(x,0,n){ int temp=tkd[i][x][y].to; if (temp==-1 || tkd[i][temp][y].to==-1) continue; edge res=edge({ tkd[i][temp][y].to, tkd[i][x][y].sum+tkd[i][temp][y].sum, min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum) }); tkd[i][x][y+1]=res; } } } } long long simulate(int CURR, int S) { ll curr=CURR,s=S; rep(x,0,sz(ds)-1){ //when we traverse a edge we cannot overshoot over some guy whos in our bucket //also sum must be contained in the bucket rep(y,30,0){ if (tkd[x][curr][y].to!=-1 && s+tkd[x][curr][y].sum<ds[x+1] && s<tkd[x][curr][y].mx){ tie(curr,s)=ii(tkd[x][curr][y].to,s+tkd[x][curr][y].sum); } } //cout<<"debug: "<<curr<<" "<<s<<endl; if (curr==n) break; //manually do extra one if (win_s[curr]<=s){ s+=win_s[curr]; curr=win_n[curr]; } else{ s+=lose_s[curr]; curr=lose_n[curr]; } } return s; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:55:35: warning: narrowing conversion of 'win_n[x]' from 'long long int' to 'int' [-Wnarrowing]
   55 |         tkd[i][x][0]=edge({win_n[x],win_s[x],(ll)1e9});
      |                            ~~~~~~~^
dungeons.cpp:58:36: warning: narrowing conversion of 'lose_n[x]' from 'long long int' to 'int' [-Wnarrowing]
   58 |         tkd[i][x][0]=edge({lose_n[x],lose_s[x],win_s[x]});
      |                            ~~~~~~~~^
dungeons.cpp:58:55: warning: narrowing conversion of 'win_s[x]' from 'long long int' to 'int' [-Wnarrowing]
   58 |         tkd[i][x][0]=edge({lose_n[x],lose_s[x],win_s[x]});
      |                                                ~~~~~~~^
dungeons.cpp:61:36: warning: narrowing conversion of 'lose_n[x]' from 'long long int' to 'int' [-Wnarrowing]
   61 |         tkd[i][x][0]=edge({lose_n[x],lose_s[x],(ll)1e9});
      |                            ~~~~~~~~^
dungeons.cpp:74:66: error: no matching function for call to 'min(int&, long long int)'
   74 |           min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum)
      |                                                                  ^
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:74:66: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |           min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum)
      |                                                                  ^
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:74:66: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   74 |           min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum)
      |                                                                  ^
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:3:
/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:74:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |           min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum)
      |                                                                  ^
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:3:
/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:74:66: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   74 |           min(tkd[i][x][y].mx,tkd[i][temp][y].mx-tkd[i][x][y].sum)
      |                                                                  ^
dungeons.cpp:75:10: error: no matching function for call to 'edge::edge(<brace-enclosed initializer list>)'
   75 |         });
      |          ^
dungeons.cpp:28:8: note: candidate: 'edge::edge()'
   28 | struct edge{
      |        ^~~~
dungeons.cpp:28:8: note:   candidate expects 0 arguments, 1 provided
dungeons.cpp:28:8: note: candidate: 'constexpr edge::edge(const edge&)'
dungeons.cpp:28:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const edge&'
dungeons.cpp:28:8: note: candidate: 'constexpr edge::edge(edge&&)'
dungeons.cpp:28:8: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'edge&&'