Submission #1187058


Source Code Expand

import java.lang.*;
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {

	public void solve(InputReader in, PrintWriter out) {
		String[] ss = new String[3];
		int[] beg = new int[3];
		int[] sz = new int[3];

		Arrays.fill(beg, 0);
		for (int i=0; i<3; ++i) {
			ss[i] = in.next();
			sz[i] = ss[i].length();
		}

		int cur = 0;

		while (beg[cur] < sz[cur]) {
			int nxt = getId(ss[cur].charAt(beg[cur]));
			beg[cur]++;
			cur = nxt;
		}

		char ans = (char)(cur + 'A');
		
		out.println(ans);
	}

	private int getId(char ch) {
		return ch - 'a';
	}
}


class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;


	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}

	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Submission Info

Submission Time
Task B - Card Game for Three (ABC Edit)
User Trasier
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 1664 Byte
Status AC
Exec Time 73 ms
Memory 23124 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status AC
AC × 12
Set Name Test Cases
Sample
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
01.txt AC 72 ms 23124 KB
02.txt AC 73 ms 21332 KB
03.txt AC 70 ms 19412 KB
04.txt AC 73 ms 19668 KB
05.txt AC 72 ms 23124 KB
06.txt AC 70 ms 21332 KB
07.txt AC 73 ms 20820 KB
08.txt AC 73 ms 19284 KB
09.txt AC 72 ms 21460 KB
10.txt AC 73 ms 19412 KB
sample_01.txt AC 71 ms 21332 KB
sample_02.txt AC 72 ms 19412 KB