hourglass.cpp: In function 'int main()':
hourglass.cpp:4:159: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
using namespace std;int n;int dist[5][7][5001];struct node{int t3,t5,ta,d;bool operator<(const node&p)const{return d>p.d;}};const int inf=1e9;int main(){scanf("%d", &n);for(int i=0;i<=4;++i){for(int j=0;j<=6;++j){for(int k=0;k<=5000;++k){dist[i][j][k] = inf;}}}priority_queue<node>pq;dist[1][1][0]=0;pq.push({0,0,0,0});while(!pq.empty()){node x=pq.top();pq.pop();if(dist[x.t3+1][x.t5+1][x.ta]!=x.d)continue;if(x.t3==0||x.t5==0){if(dist[3-max(x.t3,0)+1][x.t5+1][x.ta]>x.d+1)pq.push({3-max(x.t3,0),x.t5,x.ta,dist[3-max(x.t3,0)+1][x.t5+1][x.ta]=x.d+1});if(dist[x.t3+1][5-max(x.t5,0)+1][x.ta]>x.d+1)pq.push({x.t3,5-max(x.t5,0),x.ta,dist[x.t3+1][5-max(x.t5,0)+1][x.ta]=x.d+1});}if(x.ta<n)if(dist[max(x.t3,0)][max(x.t5,0)][x.ta+1]>x.d)pq.push({max(x.t3,0)-1,max(x.t5,0)-1,x.ta+1,dist[max(x.t3,0)][max(x.t5,0)][x.ta+1]=x.d});}int ans=inf;for(int i=0;i<=6;++i){ans=min(ans,dist[1][i][n]);if(i<=4)ans=min(ans,dist[i][1][n]);}printf("%d\n",ans<inf?ans:-1);return 0;}
~~~~~^~~~~~~~~~