/* ACM ICPC -- CERC 2011 * * Solution by: Josef Cibulka for the problem: Racing Car Trails (trails) * Idea: Alice wins from v iff v is in every maximum-size matching */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class trail { final static int MAXN=4096; final static int dirh[] = {0,1,0,-1}; final static int dirv[] = {-1,0,1,0}; int ver[]; int match[]; // the matched vertex int part[]; // the partition int ncnt[]; // number of neighbors int neigh[][]; // lists of neighbors int w, h, n; String board[]; StringTokenizer st = new StringTokenizer(""); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String nextToken() throws Exception { while (!st.hasMoreTokens()) st = new StringTokenizer(input.readLine()); return st.nextToken(); } int nextInt() throws Exception { int ret = Integer.parseInt(nextToken()); return ret; } public static void main(String[] args) throws Exception { trail inst = new trail(); for(int ii=1; ; ii++) { if (!inst.run(ii)) break; } } boolean is_empty(int r, int c) { return (r>=0 && r=0 && cqbeg) { int v = q[qbeg++]; if(part[v]==part[q[0]]) // follow a non-matching edge { for(int i=0; i