#include using namespace std; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; typedef long long int ll; int w,h; int dp[1001][1001]; int vroad[1001][1001]; int hroad[1001][1001]; int vimos[1001][1001]; int himos[1001][1001]; int main(){ int i,j,k,l; int x,y,d; int m,n; cin >>w>>h>>n; for (i=0;i=u2){ // down(flip->up) vimos[u2%w][u2/w]=max(u1/w-u2/w,vimos[u2%w][u2/w]); }else if (u1>u2){ // left himos[u2%w][u2/w]=max(u1-u2,himos[u2%w][u2/w]); }else if(u1+w>u2){ // right himos[u1%w][u1/w]=max(u2-u1,himos[u1%w][u1/w]); }else{ // up(flip->down) vimos[u1%w][u1/w]=max(u2/w-u1/w,vimos[u1%w][u1/w]); } u1=u2; } } for (x=0;x> q; q.push(vector{0,0,0}); while (!q.empty()){ vector &e=q.front(); x=e[0];y=e[1];d=e[2];q.pop(); if (dp[x][y]) continue; if (x==w-1 && y==h-1){ cout<{x-1,y,d+1});} if ( hroad[x ][y]){q.push(vector{x+1,y,d+1});} if (y!=0 && vroad[x][y-1]){q.push(vector{x,y-1,d+1});} if ( vroad[x][y ]){q.push(vector{x,y+1,d+1});} } cout<<"Odekakedekinai.."<