Skip to content

Instantly share code, notes, and snippets.

@theoremoon
Created January 12, 2015 11:52
Show Gist options
  • Save theoremoon/5108f4a175dd594eb17c to your computer and use it in GitHub Desktop.
Save theoremoon/5108f4a175dd594eb17c to your computer and use it in GitHub Desktop.
/*
* judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0104&lang=jp
* ac
*/
#include <iostream>
using namespace std;
char field[108][108];
int main() {
while(true){
start:
int h, w; cin >> h >> w;
if (h == 0 && w == 0) break;
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
cin >> field[i][j];
}
}
int x = 0, y = 0, c = 0;
while (true){
switch (field[y][x]){
case '>':
++x;
break;
case '<':
--x;
break;
case '^':
--y;
break;
case 'v':
++y;
break;
default:
printf("%d %d\n", x, y);
goto start;
break;
}
++c;
if (c > w*h) {
cout << "LOOP" << endl;
goto start;
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment