Problem:


カップゲーム

3 つのカップがふせて置かれています。カップの置かれている場所を、順に A,B,C と呼ぶことにします。最初は A に置かれているカップの中にボールが隠されているとします。カップの位置を入れ替えると、中に入っているボールも一緒に移動します。

入れ替える２つのカップの位置を読み込んで、最終的にどの場所のカップにボールが隠されているかを出力するプログラムを作成してください。

Input

入れ替える２つのカップの位置が順番に複数行にわたり与えられます。各行に、入れ替える２つのカップの位置を表す文字（A, B, または C）がカンマ区切りで与えられます。

入れ替える操作は 50 回を超えません。

Output

ボールが入っているカップの場所（A, B, または C）を１行に出力します。

Sample Input

B,C
A,C
C,B
A,B
C,B

Output for the Sample Input

A



Sample input:
B,C
A,C
C,B
A,B
C,B


Sample output:
A

Submission status: Wrong Answer

Solution code:
cap = {"A":1, "B":0, "C":0}
try:
    while True:
        tmp = raw_input().split(",")
        cap[tmp[0]] == cap[tmp[1]] 
        
except:
    if cap["A"] == 1:
        print "A"
    elif cap["B"] == 1:
        print "B"
    else:
        print "C"

Submission status: Wrong Answer

Solution code:
cap = {"A":1, "B":0, "C":0}
try:
    while True:
        tmp = raw_input().split(",")
        cap[tmp[0]], cap[tmp[1]] = cap[tmp[1]], cap[tmp[0]] 
        print cap["A"],cap["B"],cap["C"]
        
except:
    if cap["A"] == 1:
        print "A"
    elif cap["B"] == 1:
        print "B"
    else:
        print "C"

Submission status: Wrong Answer

Solution code:
ball = 0
while True:
 try:
  a, b = map(lambda x: ord(x) - ord("A"), raw_input().strip().split(","))
  if (a == ball):
   ball = b;
 except:
  break;

print chr(ball + ord("A"))

Submission status: Wrong Answer

Solution code:
from math import *
PI = 3.1415926535898
base = "A"
while True:
    try:
    	x, y = map(str, raw_input().strip().split(','))
    	if x == base:
    		base = y
    	if y == base:
    		base = x
    except EOFError:
        break
print base

Submission status: Wrong Answer

Solution code:
import sys
arr = [1,0,0]
for line in sys.stdin:
    s = line.split(',')
    if s[0] == 'A':
        n = 0
    elif s[0] == 'B':
        n = 1
    else:
        n = 2
    if s[1] == 'A':
        m = 0
    elif s[1] == 'B':
        m = 1
    else:
        m = 2
    
    if arr[n] == 1 or arr[m] == 1:
        t = arr[n]
        arr[n] = arr[m]
        arr[m] = t

for i in range(len(arr)):
    if arr[i] == 1:
        if i == 0:
            print('A')
        elif i == 1:
            print('B')
        else:
            print('C')

Submission status: Wrong Answer

Solution code:
import sys
arr = [1,0,0]
for line in sys.stdin:
    s = line.split(',')
    if s[0] == 'A':
        n = 0
    elif s[0] == 'B':
        n = 1
    else:
        n = 2
    if s[1] == 'A':
        m = 0
    elif s[1] == 'B':
        m = 1
    else:
        m = 2
    
    if arr[n] == 1 or arr[m] == 1:
        arr[n] = (arr[n]+1)%2
        arr[m] = (arr[m]+1)%2

for i in range(len(arr)):
    if arr[i] == 1:
        if i == 0:
            print('A')
        elif i == 1:
            print('B')
        else:
            print('C')

Submission status: Wrong Answer

Solution code:
import sys

d = {'A': 0, 'B': 1, 'C': 2}
cup = [1, 0, 0]

for line in sys.stdin:
  try:
    a, b = [i for i in line.split(',')]
    cup[d[a]], cup[d[b]] = cup[d[b]], cup[d[a]]
  except:
    break
if cup[0] == 1:
  print('A')
elif cup[1] == 1:
  print('B')
else:
  print('C')

Submission status: Wrong Answer

Solution code:
d = {"A":1, "B":0, "C":0}
while True:
    try:
        swap1, awap2 = input().split(",")
        d[swap1], d[swap2] = d[swap2], d[swap1]
    except:
        break
print(list(d.keys())[list(d.values()).index(1)])

Submission status: Wrong Answer

Solution code:
import sys
c='ABC'
for e in sys.stdin:c.replace(e[0],'D').replace(e[2],e[0]).replace('D',e[2])
print(c[0])

Submission status: Wrong Answer

Solution code:
import sys
c='ABC'
for e in sys.stdin:c.replace(e[0],'D').replace(e[2],e[0]).replace('D',e[2])
print('ABC'[c.index('A')])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

import sys


def exchageCup(cups, param):
    cups[param[0]], cups[param[1]] = cups[param[1]], cups[param[0]]


def main():
    params = [x.rstrip("\n").split(",") for x in sys.stdin.readlines()]
    cups = {
        "A": True,
        "B": False,
        "C": False}

    for param in params:
        print cups, param,
        exchageCup(cups, param)

    for key in cups:
        if cups[key]:
            print key


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
cap={"A":0,"B":1,"C":2}
list=["A","B","C"]
for line in sys.stdin.readlines():
    i,j=line.strip().split(",")
    list[cap[i]],list[cap[j]]=list[cap[j]],list[cap[i]]
print list[0]
#temp

Submission status: Wrong Answer

Solution code:
a=[1,0,0]
while True:
    try:
        t=raw_input().split()
        if "B"in t and "C" in t:
            a[1],a[2]=a[2],a[1]
        elif "A" in t and"C" in t:
            a[0],a[2]=a[2],a[0]
        elif "A" in t and "B" in t:
            a[1],a[0]=a[0],a[1]
    except EOFError:
        print ['A','B','C'][a.index(1)]
        break

Submission status: Wrong Answer

Solution code:
import sys
 
L = {"A":1, "B":0, "C":0}
for s in sys.stdin: 
    L[s[0]],L[s[2]] = L[s[2]],L[s[0]]
print "ABC"[L.values().index(1)]

Submission status: Time Limit Exceeded

Solution code:
d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        a, t = input().split(',')
        d[a], d[t] = d[t], d[a]
    except:
        for k, v in d.items():
            if v:
                print(k)

Submission status: Memory Limit Exceeded

Solution code:
import sys

cups = "ABC"
current = [1, 0, 0]
def swap(swap_l):
    a, b = swap_l
    a = cups.index(a)
    b = cups.index(b)
    aa = current[a]
    bb = current[b]
    current[a] = bb
    current[b] = aa

while line = sys.readline():
    line = line.strip()
    swap(line.split(','))

ans = current.index(1)
print cups[ans]

Submission status: Memory Limit Exceeded

Solution code:
import sys

cups = "ABC"
current = [1, 0, 0]
def swap(swap_l):
    a, b = swap_l
    a = cups.index(a)
    b = cups.index(b)
    aa = current[a]
    bb = current[b]
    current[a] = bb
    current[b] = aa

for line in sys.stdin:
    line = line.strip()
    swap(line.split(','))

ans = current.index(1)
print cups[ans]

Submission status: Accepted

Solution code:
di = {"A":1, "B":0, "C":0}
while(True):
    try:
        x,y = input().split(",")
        di[x],di[y] = di[y],di[x]
    except:
        print([x for x in di.keys() if di[x] == 1][0])
        break

Submission status: Accepted

Solution code:
cap = {"A":1, "B":0, "C":0}
try:
    while True:
        tmp = raw_input().split(",")
        cap[tmp[0]], cap[tmp[1]] = cap[tmp[1]], cap[tmp[0]] 
        
except:
    for k, v in cap.items():
        if v:
            print k

Submission status: Accepted

Solution code:
n=[1,0,0]
while 1:
    try:
        ch=[]
        op1,op2=list(map(str,input().split(",")))
        if op1=="A" or op2=="A":ch.append(0)
        if op1=="B" or op2=="B":ch.append(1)
        if op1=="C" or op2=="C":ch.append(2)
        n[ch[0]],n[ch[1]]=n[ch[1]],n[ch[0]]
    except:break
if n[0]==1:print("A")
if n[1]==1:print("B")
if n[2]==1:print("C")

Submission status: Accepted

Solution code:
b = {'A':1, 'B':0, 'C':0}

while True:
    try:
        n, m = input().split(',')
        b[n], b[m] = b[m], b[n]
    except:
        for i in b:
            if b[i] == 1: print(i)
        break

Submission status: Accepted

Solution code:
ball = 0
while True:
    try:
        a, b = map(lambda x: ord(x) - ord("A"), raw_input().strip().split(","))
        if (a == ball):
            ball = b;
        elif (b == ball):
            ball = a;
    except:
        break;

print chr(ball + ord("A"))

Submission status: Accepted

Solution code:
from sys import *

lis = {"A":1,"B":0,"C":0}
for s in stdin:
    d = map(str,s[:-1].split(","))
    lis[d[0]],lis[d[1]] = lis[d[1]],lis[d[0]]
for e in ["A","B","C"]:
    if lis[e]:
        print e

Submission status: Accepted

Solution code:
import sys
f = sys.stdin


cups = {'A':True, 'B':False, 'C':False}
for line in f:
    a, b = line.strip().split(',')
    cups[a], cups[b] = cups[b], cups[a]
for k, v in cups.items():
    if v:
        print(k)

Submission status: Accepted

Solution code:
A = 1;B = 0; C= 0
while True:
    try:
        M,N = raw_input().split(',')
    except EOFError:
        break
    if (M,N) == ('A','B'): A,B = B,A
    elif (M,N) == ('A','C'): A,C = C,A
    elif (M,N) == ('B','A'): B,A = A,B
    elif (M,N) == ('B','C'): B,C = C,B
    elif (M,N) == ('C','A'): C,A = A,C
    elif (M,N) == ('C','B'): C,B = B,C
        
if A == 1:print 'A'
elif B == 1: print 'B'
elif C == 1: print 'C'

Submission status: Accepted

Solution code:
data=[]
while True:
    try:
        data.append(raw_input().split(","))
    except:
        break
cup="A"
while len(data)!=0:
    p=data.pop(0)
    if cup in p:
        cup=p[p.index(cup)-1]
print cup

Submission status: Accepted

Solution code:
tokyo = {'A':1,'B':2,'C':3}

while True:
    try:
        x,y = raw_input().split(',')
        tokyo[y],tokyo[x] = tokyo[x],tokyo[y]
    except EOFError:
        print sorted(tokyo.items(), key=lambda x: x[1])[0][0]
        break

Submission status: Accepted

Solution code:
l=[1,0,0]
while 1:
    try:
        a,b=map(str,raw_input().split(","))
        l[ord(a)-65],l[ord(b)-65]=l[ord(b)-65],l[ord(a)-65]
    except:
        break
print chr(l.index(1)+65)

Submission status: Accepted

Solution code:
import sys
l = [1,0,0]
m = ['A','B','C']
for line in sys.stdin.readlines():
  line = line.replace('\n','')
  x,y = line.split(',')
  l[m.index(x)],l[m.index(y)] = l[m.index(y)],l[m.index(x)]
print(m[l.index(1)])

Submission status: Accepted

Solution code:
from math import *
PI = 3.1415926535898
base = "A"
while True:
    try:
    	x, y = map(str, raw_input().strip().split(','))
    	if x == base:
    		base = y
    	elif y == base:
    		base = x
    except EOFError:
        break
print base

Submission status: Accepted

Solution code:
def char_int(x):
	if x=='A':
		return 0
	elif x=='B':
		return 1
	else:
		return 2


cup=['A','B','C']
while True:
	try:
		a,b=map(str,input().split(','))
		x,y=char_int(a),char_int(b)
		cup[x],cup[y]=cup[y],cup[x]

	except EOFError:
		break

if cup[0]=='A':
	print('A')
elif cup[1]=='A':
	print('B')
else:
	print('C')

Submission status: Accepted

Solution code:

import sys
fe = ["A","B","C"]
for line in sys.stdin:
	num = line[:-1].split(",")
	if num[0] == "A":
		if num[1] == "B":
			tako = fe[0]
			fe[0] = fe[1]
			fe[1] = tako
		else:
			tako = fe[0]
			fe[0] = fe[2]
			fe[2] = tako

	elif num[0] == "B":
		if num[1] == "A":
			tako = fe[1]
			fe[1] = fe[0]
			fe[0] = tako
		else:
			tako = fe[1]
			fe[1] = fe[2]
			fe[2] = tako

	elif num[0] == "C":
		if num[1] == "A":
			tako = fe[0]
			fe[0] = fe[2]
			fe[2] = tako
		else:
			tako = fe[1]
			fe[1] = fe[2]
			fe[2] = tako
		
if fe.index("A") == 0: print "A"
elif fe.index("A") == 1: print "B"
else:	print "C"

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

dic = {'A':True, 'B':False, 'C':False}
for line in sys.stdin:
    c1, c2 = map(str, line.split(','))
    c2 = c2[0]
    dic[c1], dic[c2] = dic[c2], dic[c1]
for hoge in dic:
    if dic[hoge]:
        print hoge
        break

Submission status: Accepted

Solution code:
import sys
arr = {'A':1,'B':0,'C':0}
for line in sys.stdin:
    s = line.split(',')
    n = s[0]
    m = s[1][0]

    if arr[n] == 1 or arr[m] == 1:
        arr[n] = (arr[n]+1)%2
        arr[m] = (arr[m]+1)%2

for k,v in arr.items():
    if v == 1:
        print(k)

Submission status: Accepted

Solution code:
cups = {"A": 1, "B": 0, "C": 0}
while True:
    try:
        c1, c2 = raw_input().split(',')
        cups[c1], cups[c2] = cups[c2], cups[c1]
    except EOFError:
        break
    
for k, v in cups.items():
    if v:
        print k

Submission status: Accepted

Solution code:
d = {'A': True, 'B': False, 'C': False}

while True:
    try:
        a, t = input().split(',')
        d[a], d[t] = d[t], d[a]
    except:
        for k, v in d.items():
            if v:
                print(k)
        break

Submission status: Accepted

Solution code:
ans = 'A'
while True:
    try:
        s = list(input().split(','))
    except:
        break
    if len(s) == 1:
        break
    if ans in s:
        ans = s[1 - s.index(ans)]
print(ans)

Submission status: Accepted

Solution code:
place = "A"
while True:
    try:
        change=input().split(",")
        if place in change:
            place=change[change.index(place)-1]
        else:
            pass
    except:
        break
print(place)

Submission status: Accepted

Solution code:
Ans = "A"
while True:
    try:
        Pos = list(map(str,input().split(",")))
        if Pos == ['']:
            print(Ans)
            break
        if Ans in Pos:
            Ans = Pos[((Pos.index(Ans)) + 1) % 2]
    except:
        print(Ans)
        break

Submission status: Accepted

Solution code:
chg={"A":0,"B":1,"C":2}
chg2=[i for i in "ABC"]
cup=[False]*3
cup[0]=True
while True:
    try:
        a,b=input().split(",")
    except:
        break
    cup[chg[a]],cup[chg[b]]=cup[chg[b]],cup[chg[a]]
print(chg2[cup.index(True)])

Submission status: Accepted

Solution code:
chg={"A":0,"B":1,"C":2}
cup=[False]*3
cup[0]=True

while True:
    try:
        a,b=[ord(i)-65 for i in input().split(",")]
    except:
        break
    cup[a],cup[b]=cup[b],cup[a]
print(chr(65+cup.index(True)))

Submission status: Accepted

Solution code:
a={'A':1,'B':0,'C':0}
while 1:
    try:
        b,c=input().split(',')
        a[b],a[c]=a[c],a[b]
    except:
        for i in a:
            if a[i]:print(i)
        break

Submission status: Accepted

Solution code:
cup= [True, False, False]
while True:
    try:
        p= list(map(str, input().split(',')))
    except:
        break
    x, y= sorted(p)
    if x=='A' and y=='B':
        cup[0], cup[1]= cup[1], cup[0]
    elif x=='A' and y=='C':
        cup[0], cup[2]= cup[2], cup[0]
    elif x=='B' and y=='C':
        cup[1], cup[2]= cup[2], cup[1]
for i in range(3):
    if cup[i]:
        print('A' if i==0 else('B' if i==1 else 'C'))
        break

Submission status: Accepted

Solution code:
cup = {'A':1,'B':0,'C':0}
while True:
    try:
        d = list(input().split(','))
        tmp = cup[d[0]]
        cup[d[0]] = cup[d[1]]
        cup[d[1]] = tmp
    except EOFError:
        break
for c in 'ABC':
    if cup[c] == 1:
        print(c)

Submission status: Accepted

Solution code:
stat = {'A':True, 'B':False,'C':False }

while True:
    try:
        x,y = input().strip().split(',')
        z = stat[x]
        stat[x] = stat[y]
        stat[y] = z
    except EOFError:
        break
for i in stat.keys():
    if stat[i]:
        print(i)

Submission status: Accepted

Solution code:
A = 1
B = 0
C = 0
while True:
    try:
        x = list(map(str,input().split(',')))
    except EOFError:
        break
    x.sort()
    if x [0] == 'A' and x [1] == 'B':
        A,B = B,A
    elif x [0] == 'A' and x [1] == 'C':
        A,C = C,A
    else:
        B,C = C,B

if A:
    print('A')
elif B:
    print('B')
else:
    print('C')

Submission status: Accepted

Solution code:
cup = "A"
while True:
    try:
        xa,xb = input().split(",")
        if cup==xa: cup=xb
        elif cup==xb: cup = xa
    except EOFError: break
print(cup)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math
import itertools

A = [1, 0, 0]

for s in sys.stdin:
    s = s.strip()
    a, b = s.split(',')

    if a == 'A':
        i = 0
    elif a == 'B':
        i = 1
    elif a == 'C':
        i = 2

    if b == 'A':
        j = 0
    elif b == 'B':
        j = 1
    elif b == 'C':
        j = 2

    A[i], A[j] = A[j], A[i]

if A[0] == 1:
    print('A')
elif A[1] == 1:
    print('B')
else:
    print('C')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0047
Cup Game
"""
import sys


def main(args):
    ball_position = 'A'
    for line in sys.stdin:
        exchanged_cups = line.strip().split(',')
        if ball_position in exchanged_cups:
            exchanged_cups.remove(ball_position)
            ball_position = exchanged_cups[0]
    print(ball_position)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0047
Cup Game
"""
import sys


def main(args):
    ball_position = 'A'  # ?????¨??????????????\??£???????????????????????????
    for line in sys.stdin:
        exchanged_cups = line.strip().split(',')
        if ball_position in exchanged_cups:  # ??????????????\??£???????????????????????\?????????????±??????????????????´???
            exchanged_cups.remove(ball_position)  # ??\?????????????±???????????????????????????????????????\??£?????????????????????????¶????
            ball_position = exchanged_cups[0]  # ????????¨??????????????§????????????????????£??????????????????=??????????????????(?????????[0]??????)????????????????§???? 
    print(ball_position)  # ????????????????????¨?????????


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
now = 'A'
while True :
    try :
        a, b = input().split(',')
        if   now == a : now = b
        elif now == b : now = a
    except : break
print(now)

Submission status: Accepted

Solution code:
import sys
cup = {"A": 1, "B": 0, "C": 0}
for line in sys.stdin:
    if line == "\n":
        break
    x, y = line.rstrip().split(",")
    t = cup[x]
    cup[x] = cup[y]
    cup[y] = t
for key in cup:
    if cup[key] == 1:
        print(key)

Submission status: Accepted

Solution code:
# Aizu Problem 0047: Cup Game
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

IDX = {'A': 0, 'B': 1, 'C': 2}
cups = [1, 0, 0]
for line in sys.stdin:
    a, b = [IDX[_] for _ in line.strip().split(',')]
    cups[a], cups[b] = cups[b], cups[a]

print(chr(65 + cups.index(1)))

Submission status: Accepted

Solution code:
cup = {"A": 1, "B": 0, "C": 0}
while True:
    try:
        x, y = input().split(",")
    except:
        break
    cup[x], cup[y] = cup[y], cup[x]

for k, v in cup.items():
    if v:
        print(k)

Submission status: Accepted

Solution code:
import sys

d = {'A': 0, 'B': 1, 'C': 2}
cup = [1, 0, 0]

for line in sys.stdin:
  try:
    a, b = [i for i in line.split(',')]
    cup[d[a[0]]], cup[d[b[0]]] = cup[d[b[0]]], cup[d[a[0]]]
  except:
    break
if cup[0] == 1:
  print('A')
elif cup[1] == 1:
  print('B')
else:
  print('C')

Submission status: Accepted

Solution code:
def main():
    A = 1
    B = 0
    C = 0
    while True:
        try:
            cup_1,cup_2 = input().split(",")

            if cup_1 == 'A' and cup_2 == 'B' or cup_1 == 'B' and cup_2 == 'A':
                A,B = B,A
            elif cup_1 == 'B' and cup_2 == 'C' or cup_1 == 'C' and cup_2 == 'B':
                B,C = C,B
            elif cup_1 == 'A' and cup_2 == 'C' or cup_1 == 'C' and cup_2 == 'A':
                A,C = C,A
        except EOFError:
            break
    if A:
        print('A')
    elif B:
        print('B')
    elif C:
        print('C')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
d = {"A":1, "B":0, "C":0}
while True:
    try:
        swap1, swap2 = input().split(",")
        d[swap1], d[swap2] = d[swap2], d[swap1]
    except:
        break
print(list(d.keys())[list(d.values()).index(1)])

Submission status: Accepted

Solution code:
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
ans = "A"
for l in range(len(N)):
    c = N[l].split(",")
    if c[0] == ans:
        ans = c[1]
    elif c[1] == ans:
        ans = c[0]
print(ans)

Submission status: Accepted

Solution code:
import sys

def convert(s):
    x = 0
    if s == "A":
        x = 0
    elif s == "B":
        x = 1
    elif s == "C":
        x = 2
    return x

def main():
    A = [0 for i in range(3)]
    A[0] = 1

    for line in sys.stdin:
        B = line.split(",")
        B[0] = convert(B[0])
        B[1] = B[1].replace("\n", "")
        B[1] = convert(B[1])

        tmp = A[B[0]]
        A[B[0]] = A[B[1]]
        A[B[1]] = tmp
    
    S = ["A", "B", "C"]
    for i in range(3):
        if A[i] == 1:
            print(S[i])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
c='ABC'
for e in sys.stdin:c=c.replace(e[0],'D').replace(e[2],e[0]).replace('D',e[2])
print(c[0])

Submission status: Accepted

Solution code:
c = {"A":1, "B":0, "C":0}
while 1:
    try:
        x, y = input().split(",")
        c[x], c[y] = c[y], c[x]
    except:break
for k in c:
    if c[k]:print(k)

Submission status: Accepted

Solution code:
dic = {"A":0, "B":1, "C":2}
lst = [1, 0, 0]

while True:
  try:
    x, y = input().split(",")
    xi, yi = dic[x], dic[y]
    lst[xi], lst[yi] = lst[yi], lst[xi]

  except EOFError:
    break

for s in ("A", "B", "C"):
  if lst[dic[s]]:
    print(s)
    break

Submission status: Accepted

Solution code:
import sys
t=[1,0,0]
l=[[ord(j.strip())-65 for j in i.split(",")] for i in sys.stdin]
for i in l:
    t[i[0]],t[i[1]]=t[i[1]],t[i[0]]
print(chr(t.index(1)+65))

Submission status: Accepted

Solution code:
# AOJ 0047: Cup Game
# Python3 2018.6.15 bal4u

pos = 'A'
while True:
	try: x, y = list(input().split(','))
	except EOFError: break
	if x == pos: pos = y
	elif y == pos: pos = x
print(*pos)

Submission status: Accepted

Solution code:
p = "A"
while 1:
	try: a, b = list(map(str, input().split(",")))
	except: break
	if a == p: p = b
	elif b == p: p = a
print(p)

Submission status: Accepted

Solution code:
import sys
result = "A"
for (p1, p2) in (l.strip().split(",") for l in sys.stdin.readlines()):
    if result == p1:
        result = p2
    elif result == p2:
        result = p1
print(result)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

import sys


def exchageCup(cups, param):
    cups[param[0]], cups[param[1]] = cups[param[1]], cups[param[0]]


def main():
    params = [x.rstrip("\n").split(",") for x in sys.stdin.readlines()]
    cups = {
        "A": True,
        "B": False,
        "C": False}

    for param in params:
        exchageCup(cups, param)

    for key in cups:
        if cups[key]:
            print key


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
cap={"A":True,"B":False,"C":False}
for line in sys.stdin.readlines():
    i,j=line.strip().split(",")
    cap[i],cap[j]=cap[j],cap[i]
for k,v in cap.items():
    if v:print k
#temp

Submission status: Accepted

Solution code:
p = 0
chA = ord("A")

while True:
    try:
        s, t = map(lambda x: ord(x) - chA, raw_input().split(","))
    except EOFError as e:
        break
    if s == p:
        p = t
    elif t == p:
        p = s

print("%s" % (chr(p + chA), ))

Submission status: Accepted

Solution code:
p = "A"

while True:
    try:
        s, t = raw_input().split(",")
    except EOFError as e:
        break
    if s == p:
        p = t
    elif t == p:
        p = s

print("%s" % (p, ))

Submission status: Accepted

Solution code:
p = {"A":True, "B":False, "C": False}

while True:
    try:
        s, t = raw_input().split(",")
    except EOFError as e:
        break
    p[s], p[t] = p[t], p[s]

for i in p:
    if p[i]:
        print("%s" % (i, ))

Submission status: Accepted

Solution code:
def change(ball,x,y):
    tmp = ball[x]
    ball[x] = ball[y]
    ball[y] = tmp
    return ball

def jug(ball):
    ball2 = ["A","B","C"]

    for i in range(0,3):
        if ball[i] == 1:
            print ball2[i]
            break

if __name__ == "__main__":

    ball = [1,0,0]
    while True:
        try:
            x = 0
            y = 0
            z = 0

            a,b = map(str,raw_input().split(","))

            if a == "A":
                if b == "B":
                    x=0
                    y=1
		elif b == "C":
                    x=0
                    y=2
            elif a == "B":
		if b == "A":
                    x=1
                    y=0
		elif b == "C":
                    x=1
                    y=2
            elif a == "C":
		if b == "A":
                    x=2
                    y=0
		elif b == "B":
                    x=2
                    y=1

            ball = change(ball,x,y)
        except EOFError:
            break

    jug(ball)

Submission status: Accepted

Solution code:

import sys


class Cupgame:
    def __init__(self, ballin):
        self.ballin = ballin

    def swap(self, x, y):
        if x == self.ballin:
            self.ballin = y
        elif y == self.ballin:
            self.ballin = x
        else:
            pass


cupgame = Cupgame('A')

for line in sys.stdin:
    x, y = tuple(line.rstrip('\n').split(','))
    cupgame.swap(x, y)
print cupgame.ballin

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

cups = {'A': 1, 'B': 0, 'C': 0}

for line in stdin:
    t, s = line.strip().split(',')
    cups[t], cups[s] = cups[s], cups[t]

for c in 'ABC':
    if cups[c]:
        print(c)
        break

Submission status: Accepted

Solution code:
import sys

c = [1,0,0]
for s in sys.stdin:
    cc = [ord(i)-ord('A') for i in s.rstrip().split(',')]
    c[cc[0]], c[cc[1]] = c[cc[1]], c[cc[0]]
print chr(ord('A') + c.index(1))

Submission status: Accepted

Solution code:
import sys

x = [1,0,0]
L = "ABC"
for s in sys.stdin:
    a = L.index(s[0])
    b = L.index(s[2])
    x[a],x[b]=x[b],x[a]
print L[x.index(1)]

Submission status: Accepted

Solution code:
ls = {"A":0, "B":1, "C":2}
cup = [1,0,0]
while 1:
    try:
        x, y = map(str, raw_input().split(","))
        tmp = cup[ls[x]]
        cup[ls[x]] = cup[ls[y]]
        cup[ls[y]] = tmp
    except:
        break
p = cup.index(1)
if p == 0:
    print "A"
else:
    print "B" if p == 1 else "C"

Submission status: Accepted

Solution code:
import sys
 
p="A"
for s in sys.stdin:
    if p==s[0]: p=s[2]
    elif p==s[2]: p=s[0]
print p

Submission status: Accepted

Solution code:
try:
    a = 'A'
    while True:
        p, q = raw_input().split(',')
        if p == a:
            a = q
        elif q == a:
            a = p
except EOFError:
    pass
print a

Submission status: Accepted

Solution code:
Ball = {'A': 1, 'B': 0, 'C': 0}
while 1:
    try:
        a, b = raw_input().split(',')
    except EOFError:
        break
    Ball[a], Ball[b] = Ball[b], Ball[a]
for b in Ball:
    if Ball[b] == 1:
        print b

Submission status: Accepted

Solution code:
CUP = ['A', 'B', 'C']

def i(x):
    if x=='A':
        x = 0
    if x=='B':
        x = 1
    if x=='C':
        x = 2
    return x

while True:
    try:
        x, y = input().split(',')
    except:
        break
    x = i(x)
    y = i(y)
    CUP[x], CUP[y] = CUP[y], CUP[x]

ball = CUP.index('A')
if ball==0:
    print('A')
if ball==1:
    print('B')
if ball==2:
    print('C')

Submission status: Accepted

Solution code:
ans = 'A'
while True:
    try:
        a, b = input().split(',')
        if a == ans:
            ans = b
        elif b == ans:
            ans = a
        else:
            pass

    except EOFError:
        break

print(ans)

Submission status: Accepted

Solution code:
balls = [1,0,0]

while 1:
    try:
        a,b = input().split(',')
        i1 = ord(a) - ord("A")
        i2 = ord(b) - ord("A")
        balls[i1],balls[i2] = balls[i2],balls[i1]
    except:
        break
for i in range(0,3):
    if balls[i]:
        print(chr(i + ord("A")))

Submission status: Accepted

Solution code:
cup = "ABC"
while True :
    try :
        x, y = input().split(",")
        cup = cup.replace(x, "D")
        cup = cup.replace(y, x)
        cup = cup.replace("D", y)
    except EOFError :
        break
print(cup[0])

Submission status: Accepted

Solution code:
import sys
readlines = sys.stdin.readlines
write = sys.stdout.write
def solve():
    F = "ABC".index
    S = [0]*3
    S[0] = 1
    for line in readlines():
        a, b = map(F, line.strip().split(","))
        S[a], S[b] = S[b], S[a]
    write("%s\n" % "ABC"[S.index(1)])
solve()

Submission status: Accepted

Solution code:
cup = "A"
while True:
    try:
        a,b = input().split(",")
    except:
        break
    if cup == a:
        cup = b
    elif cup == b:
        cup = a
print(cup)

Submission status: Accepted

Solution code:
list=[]
cup={'A':1,'B':0,'C':0}
while True:
    try:
        x,y=map(str, input().split(','))
    except:
        keys=[k for k,v in cup.items() if v==1]
        for i in range(len(keys)):
            print(keys[i])
        break
    if cup[x]==1:
        cup[y]=1
        cup[x]=0
    elif cup[y]==1:
        cup[y]=0
        cup[x]=1

Submission status: Accepted

Solution code:
L = [ 1, 0, 0]

d = {}
for i in range(len("ABC")):
    d["ABC"[i]] = i

while True:
    try:
        s, t = input().split(",")
        L[d[s]], L[d[t]] = L[d[t]], L[d[s]]
        pass
    except EOFError:
        break
    
for i in range(len(L)):
    if L[i] > 0:
        print("ABC"[i])

Submission status: Accepted

Solution code:
m={'A':0,'B':1,'C':2}
a = 'A'
b='B'
while True:
    try:
        a, b = list(input().split(','))
    except:
        break
    m[a],m[b]=m[b],m[a]

if m['A']==0:  print('A')
elif m['B']==0:   print ('B')
elif m['C']==0:  print('C')

Submission status: Accepted

Solution code:
b = {'A': 1, 'B': 0, 'C': 0}

while 1:
    try:
        x, y = input().split(',')
        b[x], b[y] = b[y], b[x]
    except:
        for i in b.keys():
            if b[i]:
                print(i)
        break