Submission #2331799


Source Code Expand

import java.util.*;
public class Main {
	static int n;
	static ArrayList<String> jukugo;
	static String ans;
	static char current;
	static void dfs(String tlrb, boolean[] ini, int depth){
		if(depth == 4){
			ans += current;
			return;
		}
		int pos = ini[depth] ? 0:1;
		for(int i=0;i<n;i++){
			String tmp = jukugo.get(i);
			if(tlrb.charAt(depth) == tmp.charAt(pos)){
//				System.out.println("tmp:"+tmp);
				if(depth == 0){
					current = tmp.charAt(1 - pos);
//					System.out.println("current:" + current);
				}
				if(current == tmp.charAt(1-pos)){
//					System.out.println("depth:" + depth);
					dfs(tlrb,ini,depth+1);
				}
			}
		}
	}

	public static void main(String[] args){
		jukugo = new ArrayList<String>();
		Scanner sc = new Scanner(System.in);
		sc.hasNext();
		n = Integer.parseInt(sc.nextLine());
		for(int i=0;i<n;i++){
			sc.hasNext();
			jukugo.add(sc.nextLine());
		}
		ans="";
		while(sc.hasNext()){
			String tlrb="";
			boolean[] ini = new boolean[4];
			String[] tmp = new String[5];
			for(int i=0;i<5;i++){
				if(i!=0)sc.hasNext();
				tmp[i] = sc.nextLine();
//				System.out.println(tmp[i]);
			}
			tlrb += tmp[0].charAt(2);
			tlrb += tmp[2].charAt(0);
			tlrb += tmp[2].charAt(4);
			tlrb += tmp[4].charAt(2);
			ini[0] = tmp[1].charAt(2) == 0x2193;
			ini[1] = tmp[2].charAt(1) == 0x2192;
			ini[2] = tmp[2].charAt(3) == 0x2190;
			ini[3] = tmp[3].charAt(2) == 0x2191;
			dfs(tlrb,ini,0);
//				System.out.println("tlrb:"+tlrb);
		}
		System.out.println(ans);
/*		System.out.println(jukugo.size());
		for(int i=0;i<jukugo.size();i++) System.out.println(jukugo.get(i));
		System.out.println("↓ho↑ge←hoge□h→");*/
	}
}

Submission Info

Submission Time
Task E - 必殺!無限覇王斬!
User latte0119
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1731 Byte
Status CE

Compile Error

./Main.cpp:1:1: error: ‘import’ does not name a type
 import java.util.*;
 ^
./Main.cpp:2:1: error: expected unqualified-id before ‘public’
 public class Main {
 ^