Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Created October 16, 2013 01:22
Show Gist options
  • Save cocodrips/7001229 to your computer and use it in GitHub Desktop.
Save cocodrips/7001229 to your computer and use it in GitHub Desktop.
SRM594 div2 250
public class FoxAndClassroom {
public String ableTo(int n, int m) {
boolean[][] seated = new boolean[n][];
for (int i = 0; i < seated.length; i++) {
seated[i] = new boolean[m];
}
int r = 0;
int c = 0;
seated[r][c] = true;
for (int i = 1; i < n * m; i++) {
r = (r + 1) % n;
c = (c + 1) % m;
if (seated[r][c]) {
return "Impossible";
}
}
return "Possible";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment