codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
//ladder #include <iostream> #include <conio.h> using namespace std; #define max 100 int main() { int n, i, j; int maze[max][max]; freopen("Testcase.txt", "r", stdin); for(int testcase = 1; testcase <= 10; testcase++) { int col, row; cin >> n; for(i = 0; i < max; i++) { for(j = 0; j < max; j++) { cin >> maze[i][j]; if(maze[i][j] == 2) { row = i; col = j; } } } while(row >= 0) { if(col > 0 && maze[row][col-1] == 1) { maze[row][col] = 0; col--; continue; } if(col < max - 1 && maze[row][col+1] == 1) { maze[row][col] = 0; col++; continue; } row--; } cout << "#" << testcase << " " << col << endl; } getch(); return 0; }
Private
[
?
]
Run code
Submit