#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; template istream& operator >> (istream& is, vector& vec){for(T& val: vec) is >> val; return is;} template istream& operator , (istream& is, T& val){ return is >> val;} template ostream& operator << (ostream& os, vector& vec){for(int i=0; i ostream& operator , (ostream& os, T& val){ return os << " " << val;} template ostream& operator >> (ostream& os, T& val){ return os << " " << val;} #include using bits = bitset<2047>; int main(){ int w,h,n; cin >> w,h,n; vector> tate(2*h+1, vector(w+1, 0)); vector> yoko(h+1, vector(2*w+1, 0)); for(int i=0; i ver(w); vector hol(h); for(int i=0; i0) hol[i].set(j); } } for(int j=0; j0) ver[j].set(i); } } vector> dist(h+1, vector(w+1, 10000000)); dist[0][0] = 0; vector dx = {0,0,1,-1}; vector dy = {1,-1,0,0}; queue> q; q.push({0,0}); while(q.size()){ auto pos = q.front(); q.pop(); int x = pos.second; int y = pos.first; for(int k__=0; k__<4; k__++){ int new_x = x + dx[k__]; int new_y = y + dy[k__]; if(new_x < 0 || new_x >= w || new_y < 0 || new_y >= h) continue; if((x==new_x) ? ver[x][y+new_y] : hol[y][x+new_x]){ if(dist[new_y][new_x] > dist[y][x] + 1){ dist[new_y][new_x] = dist[y][x]+1; q.push({new_y, new_x}); } } } } if(dist[h-1][w-1] != 10000000){ cout << dist[h-1][w-1] << endl; }else{ cout << "Odekakedekinai.." << endl; } return 0; }