Submission #785378

#TimeUsernameProblemLanguageResultExecution timeMemory
785378KLPPMaze (JOI23_ho_t3)C++14
27 / 100
2093 ms17760 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef long long int lld; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; #define rep(i,a,b) for(int i=a;i<b;i++) #define trav(a,v) for(auto a:v) int r,c,n; int valid(int x, int y){ if(x>=0 && x<r && y>=0 && y<c)return true; return false; } void solve(){ cin>>r>>c>>n; int sx,sy; cin>>sx>>sy; sx--;sy--; int gx,gy; cin>>gx>>gy; gx--;gy--; vector<string> V(r); rep(i,0,r)cin>>V[i]; deque<tuple<int,int,int> >q; vector<vector<int> >dist(r); rep(i,0,r)dist[i].resize(c,1000000000); dist[sx][sy]=0; q.push_back({sx,sy,0}); while(!q.empty()){ auto [x,y,d]=q.front(); q.pop_front(); if(d>dist[x][y])continue; if(V[x][y]=='.'){ rep(dx,x-1,x+2){ rep(dy,y-1,y+2){ if(abs(dx-x)+abs(dy-y)==1){ if(valid(dx,dy)){ if(dist[dx][dy]>d){ dist[dx][dy]=d; q.push_front({dx,dy,d}); } } } } } } rep(dx,x-n,x+n+1){ rep(dy,y-n,y+n+1){ if(abs(dx-x)+abs(dy-y)<=2*n-1){ if(valid(dx,dy)){ if(dist[dx][dy]>d+1){ dist[dx][dy]=d+1; q.push_back({dx,dy,d+1}); } } } } } } cout<<dist[gx][gy]<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); int tt=1; //cin>>tt; while(tt--){ solve(); } }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:35:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   35 |   auto [x,y,d]=q.front();
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...