problem_id
stringlengths 1
4
| problem_name
stringlengths 9
108
| solution_id
stringlengths 3
10
| time_complexity_inferred
stringclasses 439
values | space_complexity_inferred
stringclasses 262
values | query_code
stringlengths 11
464k
|
|---|---|---|---|---|---|
1100
|
79_A. Bus Game
|
1100_0
|
O(n)
|
O(1)
|
player_one = 'Ciel'
player_two = 'Hanako'
c100, c10 = map(int, input().split())
full_moves = min([c100 // 2, c10 // 24])
c100 -= full_moves * 2
c10 -= full_moves * 24
while True:
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
tmp = min([2, c100])
c100 -= tmp
c10 -= (220 - 100 * tmp) // 10
else:
print(player_two)
break
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
if c10 >= 22:
c10 -= 22
elif c10 >= 12:
c10 -= 12
c100 -= 1
else:
c10 -= 2
c100 -= 2
else:
print(player_one)
break
|
1100
|
79_A. Bus Game
|
1100_1
|
O(n)
|
O(1)
|
import re
import itertools
from collections import Counter
class Task:
x, y = 0, 0
answer = ""
def getData(self):
self.x, self.y = [int(x) for x in input().split(' ')]
#inFile = open('input.txt', 'r')
#inFile.readline().rstrip()
#self.childs = inFile.readline().rstrip()
def solve(self):
while True:
if self.cielStep() == "can't move":
self.answer = 'Hanako'
return
if self.hanakoStep() == "can't move":
self.answer = 'Ciel'
return
def cielStep(self):
if self.x >= 2 and self.y >= 2:
self.x -= 2
self.y -= 2
return 'next'
if self.x >= 1 and self.y >= 12:
self.x -= 1
self.y -= 12
return 'next'
if self.y >= 22:
self.y -= 22
return 'next'
return "can't move"
def hanakoStep(self):
if self.y >= 22:
self.y -= 22
return 'next'
if self.y >= 12 and self.x >= 1:
self.y -= 12
self.x -= 1
return 'next'
if self.y >= 2 and self.x >= 2:
self.x -= 2
self.y -= 2
return 'next'
return "can't move"
def printAnswer(self):
print(self.answer)
#outFile = open('output.txt', 'w')
#outFile.write(self.answer)
task = Task()
task.getData()
task.solve()
task.printAnswer()
|
1100
|
79_A. Bus Game
|
1100_2
|
O(nlogn)
|
O(1)
|
# bsdk idhar kya dekhne ko aaya hai, khud kr!!!
# import math
# from itertools import *
# import random
# import calendar
import datetime
# import webbrowser
hundred_coin, ten_coin = map(int, input().split())
won = 0
for i in range(0, 10000000):
if i % 2 == 0:
ciel_money = 0
# wrote code for ciel
if hundred_coin >= 2:
hundred_coin -= 2
ciel_money += 2 * 100
if ten_coin >= 2:
ciel_money += 2*10
ten_coin -= 2
else:
won = "Hanako"
break
else:
if hundred_coin == 1:
hundred_coin = 0
ciel_money += 100
if ten_coin >= 12:
ciel_money += 120
ten_coin -= 12
elif ten_coin >= 11:
ciel_money += 110
ten_coin -= 11
else:
won = "Hanako"
break
else:
if ten_coin >= 22:
ciel_money += 220
ten_coin -= 22
else:
won = "Hanako"
break
if ciel_money == 220:
continue
else:
won = "Hanako"
break
elif i % 2 != 0:
hanako_money = 0
# now for hanako
if ten_coin >= 22:
hanako_money += 220
ten_coin -= 22
elif ten_coin >= 12:
hanako_money += 120
ten_coin -= 12
if hundred_coin > 0:
hanako_money += 100
hundred_coin -= 1
else:
won = "Ciel"
break
elif ten_coin >= 2:
hanako_money += 20
ten_coin -= 2
if hundred_coin >= 2:
hanako_money += 200
hundred_coin -= 2
elif hundred_coin == 1:
hanako_money += 100
hundred_coin -= 1
else:
won = "Ciel"
break
else:
won = "Ciel"
break
if hanako_money == 220:
continue
else:
won = "Ciel"
break
print(won)
|
1100
|
79_A. Bus Game
|
1100_3
| null | null |
x, y =map(int, input().split())
p = True
dez = [2, 12, 22]
cem = [2,1,0]
while True:
# print(x, y)
if p:
for i in range(3):
if x >= cem[i] and y >= dez[i]:
x -= cem[i]
y -= dez[i]
break
else:
print("Hanako")
exit()
else:
for i in range(2, -1, -1):
# print(cem[i], dez[i])
if x >= cem[i] and y >= dez[i]:
x -= cem[i]
y -= dez[i]
break
else:
print("Ciel")
exit()
p = not p
|
1100
|
79_A. Bus Game
|
1100_4
|
O(n)
|
O(1)
|
state = 1
x, y = map(int, input().split())
while True:
state = 1-state
if state == 0:
if x >= 2 and y >= 2:
x -= 2
y -= 2
continue
elif x >= 1 and y >= 12:
x -= 1
y -= 12
continue
elif x >= 0 and y >= 22:
x -= 0
y -= 22
continue
else:
break
elif state == 1:
if x >= 0 and y >= 22:
x -= 0
y -= 22
continue
elif x >= 1 and y >= 12:
x -= 1
y -= 12
continue
elif x >= 2 and y >= 2:
x -= 2
y -= 2
continue
else:
break
print(['Hanako', 'Ciel'][state])
|
1100
|
79_A. Bus Game
|
1100_5
|
O(nlogn)
|
O(1)
|
x,y=map(int,input().split())
i=0
sum=x*100+y*10
while (sum>=220):
if (y<2):
break
if (i%2==0):
if (x>=2):
x-=2
if (y>=2):
y-=2
else:
break
else:
if (x==1):
x-=1
y-=12
else:
if (y>=22):
y-=22
else:
break
else:
if (y>=22):
y-=22
else:
if (y>=12):
y-=12
x-=1
elif (y>=2):
y-=2
x-=2
sum-=220
i+=1
if (i%2==0):
print("Hanako")
else:
print ("Ciel")
|
1100
|
79_A. Bus Game
|
1100_6
|
O(n)
|
O(1)
|
x,y = [int(z) for z in input().split()]
n = 1
if x//2>0 and y//24 >0 :
n = min(x//2,y//24)
x -= 2 * n
y -= 24 * n
if (n%2 == 0):
n += 1
while(True):
#print (n,x,y)
if n%2 :
if y < 2:
print('Hanako')
break
y -= 2
if x < 2:
tmp = (200 - x*100)//10
if y < tmp :
print('Hanako')
break
else:
y -= tmp
x = 0
else:
x -= 2
# print('c',x,y)
else:
if y < 2:
print('Ciel')
break
if y < 22 :
y -= 2
tmp = (y * 10)//100
y -= (tmp *100)//10
if x < tmp :
print('Ciel')
break
else:
if x < (2 - tmp):
print('Ciel')
break
x -= (2 - tmp)
else:
y -= 22
# print ('h',x,y)
n += 1
|
1100
|
79_A. Bus Game
|
1100_7
|
O(nlogn)
|
O(1)
|
x,y=map(int,input().split())
cnt=0
while(True):
if(cnt%2==0):
if(x>=2 and y>=2):
x-=2
y-=2
cnt+=1
elif(x>=1 and y>=12):
x-=1
y-=12
cnt+=1
elif(y>=22):
y-=22
cnt+=1
else:
break
else:
if(y>=22):
y-=22
cnt+=1
elif(x>=1 and y>=12):
x-=1
y-=12
cnt+=1
elif(x>=2 and y>=2):
x-=2
y-=2
cnt+=1
else:
break
print("Ciel" if cnt%2==1 else "Hanako")
|
1100
|
79_A. Bus Game
|
1100_8
|
O(nlogn)
|
O(1)
|
n = input().split()
x = int(n[0])
y = int(n[1])
t = 0
a = [0]*2
a[0] = "Ciel"
a[1] = "Hanako"
while True:
if t % 2==0:
if y >=2:
if x >= 2:
x -=2
y -=2
elif x == 1 and y >= 12:
x -=1
y -= 12
elif x ==0 and y >= 22:
y -= 22
else:
break
else:
break
else:
if y >= 22:
y -=22
elif y >= 12 and x >= 1:
y -= 12
x -= 1
elif y >= 2 and x >=2:
y -=2
x -=2
else:
break
t +=1
res = a[(t+1)%2]
print(res)
|
1100
|
79_A. Bus Game
|
1100_9
|
O(n)
|
O(1)
|
import re
import itertools
from collections import Counter
class Task:
x, y = 0, 0
answer = ""
def getData(self):
self.x, self.y = [int(x) for x in input().split(' ')]
#inFile = open('input.txt', 'r')
#inFile.readline().rstrip()
#self.childs = inFile.readline().rstrip()
def solve(self):
while True:
if self.cielStep() == "can't move":
self.answer = 'Hanako'
return
if self.hanakoStep() == "can't move":
self.answer = 'Ciel'
return
def cielStep(self):
if self.x >= 2 and self.y >= 2:
self.x -= 2; self.y -= 2
return 'next'
if self.x >= 1 and self.y >= 12:
self.x -= 1
self.y -= 12
return 'next'
if self.y >= 22:
self.y -= 22
return 'next'
return "can't move"
def hanakoStep(self):
if self.y >= 22:
self.y -= 22
return 'next'
if self.y >= 12 and self.x >= 1:
self.y -= 12
self.x -= 1
return 'next'
if self.y >= 2 and self.x >= 2:
self.x -= 2
self.y -= 2
return 'next'
return "can't move"
def printAnswer(self):
print(self.answer)
#outFile = open('output.txt', 'w')
#outFile.write(self.answer)
task = Task()
task.getData()
task.solve()
task.printAnswer()
|
1100
|
79_A. Bus Game
|
1100_10
|
O(n)
|
O(1)
|
Piles= {}
Piles[100], Piles[10] = [int(x) for x in input().split()]
while True:
#Ceil's Turn, wins if she gets 220 coins
SumOfYens = min(2, Piles[100]) * 100
Piles[100] -= min(2, Piles[100])
if (220 - SumOfYens)/10 <= Piles[10]: Piles[10] -= (220 - SumOfYens)/10
else: print("Hanako"); break
#Hanako's Turn
if Piles[10] >= 22: Piles[10] -= 22
elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1
elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2
else: print("Ciel"); break
|
1100
|
79_A. Bus Game
|
1100_11
|
O(n)
|
O(1)
|
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def MAP2():return map(float,input().split())
def LIST(): return list(map(int, input().split()))
def STRING(): return input()
import string
import sys
from heapq import heappop , heappush
from bisect import *
from collections import deque , Counter
from math import *
from itertools import permutations , accumulate
dx = [-1 , 1 , 0 , 0 ]
dy = [0 , 0 , 1 , - 1]
#visited = [[False for i in range(m)] for j in range(n)]
#sys.stdin = open(r'input.txt' , 'r')
#sys.stdout = open(r'output.txt' , 'w')
#for tt in range(INT()):
x, y = MAP()
flag1 = True
flag2 = True
f = 0
while True:
if f == 0 :
v = 220
k = min(x , 2)
x -= k
k1 = k * 100
v-= k1
k2 = v // 10
if y >= k2 :
y-= k2
v = v % 10
if v > 0 :
flag1 = False
break
else:
f = 1
else:
flag1 = False
break
else:
v2 = 220
if y >= 22 :
y -= 22
f = 0
else:
if x == 0 :
flag2 = False
break
else:
v2 -= 100
x-=1
if y >= 12:
v2 = 0
y -= 12
f = 0
else:
v2 -= 100
x-=1
if x < 0 :
flag2 = False
break
else:
v2 -= 20
y-=2
if y < 0 :
flag2 = False
break
else:
f = 0
#print(flag1)
#print(flag2)
if flag1:
print('Ciel')
else:
print('Hanako')
|
1100
|
79_A. Bus Game
|
1100_12
|
O(1)
|
O(1)
|
def f(a, b):
k = min(a, 2)
return a - k, b - 22 + 10 * k
def g(a, b):
if b > 21: return a, b - 22
if b > 11: return a - 1, b - 12
return a - 2, b - 2
def main():
a, b = map(int, input().split())
k = min(a // 2, b // 24)
a -= 2 * k
b -= 24 * k
while a > 0:
a, b = f(a, b)
if a < 0 or b < 0: return 0
a, b = g(a, b)
if a < 0 or b < 0: return 1
if a == 0: return (b // 22) % 2
print(['Hanako', 'Ciel'][main()])
|
1100
|
79_A. Bus Game
|
1100_13
|
O(n)
|
O(1)
|
x, y = map(int, input().split())
CielWon = False
while (y > 1 and x * 10 + y > 21):
t = min(x, 2)
x -= t
y -= (2 - t) * 10 + 2
if (y < 2 or 10 * x + y < 22):
CielWon = True
break
y -= 2
t = min(2, y // 10)
y -= 10 * t
x -= 2 - t
print ('Ciel' if CielWon else 'Hanako')
|
1100
|
79_A. Bus Game
|
1100_14
|
O(1)
|
O(1)
|
def busgame():
x, y = map(int, input().split())
turn = True
while True:
if y < 2:
break
y -= 2
if turn:
if x >= 2:
x -= 2
elif x >= 1 and y >= 10:
x -= 1
y -= 10
elif y >= 20:
y -= 20
else:
break
else:
if y >= 20:
y -= 20
elif x >= 1 and y >= 10:
x -= 1
y -= 10
elif x >= 2:
x -= 2
else:
break
turn = not turn
if not turn:
print('Ciel')
else:
print('Hanako')
if __name__ == '__main__':
busgame()
|
1100
|
79_A. Bus Game
|
1100_15
|
O(n)
|
O(1)
|
hundred, ten = [int(x) for x in input().split()]
total = 100*hundred + 10*ten
#reduce by number of rounds where Ciel can take 2 100-yen and 2 10-yen, and Hanako can take 22 10-yen
skipped = min(hundred//2,ten//24)
hundred = hundred - 2*skipped
ten = ten - 24*skipped
while True:
win = 0
if hundred >= 2 and ten >= 2:
hundred = hundred - 2
ten = ten - 2
elif hundred >= 1 and ten >= 12:
hundred = hundred - 1
ten = ten - 12
elif ten >= 22:
ten = ten - 22
else:
break
win = 1
if ten >= 22:
ten = ten - 22
elif hundred >= 1 and ten >= 12:
hundred = hundred - 1
ten = ten - 12
elif hundred >= 2 and ten >= 2:
hundred = hundred - 2
ten = ten - 2
else:
break
if win == 0:
print ("Hanako")
else:
print ("Ciel")
|
1100
|
79_A. Bus Game
|
1100_16
|
O(1)
|
O(1)
|
n , m = map(int,input().split())
c = min(n//2 , m//24)
n-=(2*c)
m-=(24*c)
c = min(n//3 , m//14)
n-=(3*c)
m-=(14*c)
c = min(n//4, m//4)
n-=(4*c)
m-=(4*c)
c = min(n , m//32)
n-=(c)
m-=(32*c)
c=m//44
m-=(44*c)
if m>=2 and 10*n +m >=22:
print("Ciel")
else:
print("Hanako")
|
1100
|
79_A. Bus Game
|
1100_17
|
O(nlogn)
|
O(1)
|
x,y=map(int,input().split())
def solve(x,y):
valuex=100*x
valuey=10*y
count=0
while True:
if count%2==0:
if x>=2 and y>=2:
x-=2
valuex-=200
y-=2
valuey-=20
count+=1
elif x==1 and y>=12:
x-=1
valuex-=100
y-=12
valuey-=120
count+=1
elif x==0 and y>=22:
y-=22
valuey-=220
count+=1
else:
return "Hanako"
else:
if y>=22:
y-=22
valuey-=220
count+=1
elif x>0 and y>=12:
x-=1
valuex-=1
y-=12
valuey-=120
count+=1
elif x>1 and y>=2:
x-=2
valuex-=200
y-=2
valuey-=20
count+=1
else:
return "Ciel"
print(solve(x,y))
|
1100
|
79_A. Bus Game
|
1100_18
| null | null |
n, m = map(int, input().split())
i = 1
while 2 > 1:
if(i & 1):
if(n * 100 + m * 10 >= 220):
if(n >= 2 and m >= 2):
n -= 2
m -= 2
elif(m >= 12 and n >= 1):
m -= 12
m -= 1
elif(m >= 22):
m -= 22
else:
print('Hanako')
exit(0)
else:
print('Hanako')
exit(0)
else:
if(n * 100 + m * 10 >= 220):
if(m >= 22):
m -= 22
elif(n >= 1 and m >= 12):
n -= 1
m -= 12
elif(n >= 2 and m >= 2):
n -= 2
m -= 2
else:
print('Ciel')
exit(0)
else:
print('Ciel')
exit(0)
i += 1
|
1100
|
79_A. Bus Game
|
1100_19
|
O(n)
|
O(1)
|
a, b = map(int,input().split())
k = "Hanako"
z = False
while True:
if z == True:break
if k == 'Ciel':
if b >= 22:
b -= 22
k = 'Hanako'
elif b >= 12 and a >= 1:
a-= 1
b-= 12
k = 'Hanako'
elif b >= 2 and a >= 2:
a -= 2
b -= 2
k = 'Hanako'
else:z = True
else:
if a >= 2 and b > 1:
a -= 2
b -= 2
k = 'Ciel'
elif a == 1 and b > 11:
a -= 1
b -= 12
k = 'Ciel'
elif a == 0 and b > 21:
b -= 22
k = 'Ciel'
else:z = True
print(k)
|
1100
|
79_A. Bus Game
|
1100_20
|
O(nlogn)
|
O(1)
|
n, a = map(int, input().split())
ans = 0
while(1):
s =220
op=-1
if a < 2: break
if ans%2 == 0:
l = min(n, 2)
s -= l*100
k = min(a ,s//10)
s -= k*10
n -= l
a -= k
else:
k = min((a-2)//10 , 2)
s -= k*100
l = min(n, s//100)
s -= l*100
a -= k*10
op = min(a, s//10)
s -= op*10
n -= l
a -= op
if s != 0:
break
ans += 1
if ans%2 == 1:
print('Ciel')
else:
print('Hanako')
|
1100
|
79_A. Bus Game
|
1100_21
| null | null |
inp1, inp2 = [int(i) for i in input().split()]
hundred = 100 * inp1
ten = 10 * inp2
lista = ["Ciel", "Hanako"] * 1000000
for i in range(len(lista)):
if i % 2 == 0:
if (hundred >= 200 and ten >= 20):
hundred = hundred - 200
ten = ten - 20
elif (hundred >= 100 and ten >= 120):
hundred = hundred - 100
ten = ten - 120
elif (hundred == 0 and ten >= 220):
ten = ten - 220
else:
print("Hanako")
exit()
else:
if (ten >= 220):
ten = ten - 220
elif (ten >= 120 and hundred >= 100):
ten = ten - 120
hundred = hundred - 100
elif (ten >= 20 and hundred >= 200):
ten = ten - 20
hundred = hundred - 200
else:
print("Ciel")
exit()
|
1100
|
79_A. Bus Game
|
1100_22
|
O(n)
|
O(1)
|
x, y = list(map(int, input().split()))
f = 1
while (True):
if f == 1:
if x >= 2 and y >= 2: x -= 2; y -= 2
elif x >= 1 and y >= 12: x -= 1; y -= 12
elif y >= 22: y -= 22
else:
print("Hanako")
break
else:
if y >= 22: y -= 22
elif y >= 12 and x >= 1: y -= 12; x -= 1
elif y >= 2 and x >= 2: y -= 2; x -= 2
else:
print("Ciel")
break
f *= -1
|
1100
|
79_A. Bus Game
|
1100_23
|
O(n)
|
O(1)
|
x,y=map(int,input().split())
while(True):
if x>=2 and y>=2:
x=x-2
y=y-2
elif y>=22:
y=y-22
elif x>=1 and y>=12:
x=x-1
y=y-12
else:
print("Hanako")
break
if y>=22:
y=y-22
elif x>=1 and y>=12:
x=x-1
y=y-12
elif x>=2 and y>=2:
x=x-2
y=y-2
else:
print("Ciel")
break
|
1100
|
79_A. Bus Game
|
1100_24
|
O(n)
|
O(1)
|
def busgame(x,y):
while 1:
if x >= 2 and y >= 2:
x -= 2
y -= 2
elif x == 1 and y >= 12:
x -= 1
y -= 12
elif x == 0 and y >= 22:
y -= 22
else:
return 'Hanako'
if y >= 22:
y -= 22
elif 22 > y >= 12 and x >= 1:
y -= 12
x -= 1
elif 12 > y > 1 and x >= 2:
y -= 2
x -= 2
else:
return 'Ciel'
x, y = [int(x) for x in input().split()]
print(busgame(x,y))
|
1100
|
79_A. Bus Game
|
1100_25
|
O(n)
|
O(1)
|
player_one = 'Ciel'
player_two = 'Hanako'
c100, c10 = map(int, input().split())
while True:
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
tmp = min([2, c100])
c100 -= tmp
c10 -= (220 - 100 * tmp) // 10
else:
print(player_two)
break
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
if c10 >= 22:
c10 -= 22
elif c10 >= 12:
c10 -= 12
c100 -= 1
else:
c10 -= 2
c100 -= 2
else:
print(player_one)
break
|
1100
|
79_A. Bus Game
|
1100_26
| null | null |
x,y=map(int,input().split())
t=0
while True:
if t%2==0:
if x>=2 and y>=2:
x-=2;y-=2
elif x==1 and y>=12:
x-=1;y-=12
elif x==0 and y>=22:
y-=22
else:exit(print('Hanako'))
else:
if y>=22:
y-=22
elif x>=1 and y>=12:
y-=12;x-=1
elif x>=2 and y>=2:
x-=2;y-=2
else:exit(print('Ciel'))
t+=1
|
1100
|
79_A. Bus Game
|
1100_27
|
O(1)
|
O(n)
|
player_one = 'Ciel'
player_two = 'Hanako'
c100, c10 = map(int, input().split())
full_moves = min([c100 // 2, c10 // 24])
c100 -= full_moves * 2
c10 -= full_moves * 24
if c100 < 2:
solved = False
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
c10 -= (220 - 100 * c100) // 10
c100 = 0
else:
print(player_two)
solved = True
if not solved:
if (c10 // 22) % 2 == 1:
print(player_two)
else:
print(player_one)
else:
while True:
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
tmp = min([2, c100])
c100 -= tmp
c10 -= (220 - 100 * tmp) // 10
else:
print(player_two)
break
if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:
if c10 >= 22:
c10 -= 22
elif c10 >= 12:
c10 -= 12
c100 -= 1
else:
c10 -= 2
c100 -= 2
else:
print(player_one)
break
|
1100
|
79_A. Bus Game
|
1100_28
|
O(nlogn)
|
O(1)
|
a,b = map(int,input().split())
x=1
while True:
if x%2:
if a>=0 and b>0:
if a>=2:
if b>=2:
a-=2
b-=2
x+=1
elif b<2:
print('Hanako')
break
elif a==1:
if b>=12:
b-=12
a-=1
x+=1
else:
print('Hanako')
break
elif a==0:
if b>=22:
b-=22
x+=1
else:
print('Hanako')
break
else:
print('Hanako')
break
else:
if a>=0 and b>0:
if b>=22:
b-=22
x+=1
else:
if a>=1 and b>=12:
a-=1
b-=12
x+=1
elif a>=2 and b>=2:
a-=2
b-=2
x+=1
else:
print('Ciel')
break
else:
print('Ciel')
break
|
1100
|
79_A. Bus Game
|
1100_29
|
O(n)
|
O(1)
|
'''
13.07.2021
CF 071 A
'''
s = (input ()).split ()
x = int (s [0])
y = int (s [1])
go = 0
while x*10 + y >= 22 :
if go == 0 :
if x >= 2 and y >= 2 :
x -= 2; y -= 2
elif x == 1 and y >= 12 :
x -= 1; y -= 12
elif x == 0 and y >= 22 :
y -= 22
else :
break
else :
if y >= 22 :
y -= 22
elif x >= 1 and y >= 12 :
x -= 1; y -= 12
elif x >= 2 and y >= 2 :
x -= 2; y -= 2
else :
break
go = 1 - go
if go == 0 :
print ("Hanako")
else :
print ("Ciel")
|
1100
|
79_A. Bus Game
|
1100_30
| null | null |
x,y=map(int,input("").split())
c=0
i=0
while(c==0):
if i%2==0:
if x>=2:
x=x-2
if y>=2:
y=y-2
else:
break
elif x<2:
s=(220-(x*100))//10
if y>=s:
y=y-s
else:
break
else:
if y>=22:
y=y-22
elif y<22 and y>=12:
y=y-12
if x>=1:
x=x-1
else:
break
elif y<12 and y>=2:
y=y-2
if x>=2:
x=x-2
else:
break
else:
break
i+=1
if i%2==0:
print("Hanako")
else:
print("Ciel")
|
1100
|
79_A. Bus Game
|
1100_31
|
O(n)
|
O(1)
|
Piles, Ceil, Hanako= {}, 1, 1
Piles[100], Piles[10] = [int(x) for x in input().split()]
while True:
#Ceil's Turn, wins if she gets 220 coins
SumOfYens = min(2, Piles[100]) * 100
Piles[100] -= min(2, Piles[100])
if (220 - SumOfYens)/10 <= Piles[10]: Piles[10] -= (220 - SumOfYens)/10
else: Ceil = 0
if Ceil == 0: break
#Hanako's Turn
if Piles[10] >= 22: Piles[10] -= 22
elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1
elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2
else: Hanako = 0
if Hanako == 0: break
if Ceil == 0: print("Hanako")
else: print("Ciel")
|
1100
|
79_A. Bus Game
|
1100_32
|
O(nlogn)
|
O(1)
|
x,y=list(map(int,input().split()))
cnt=0
while True:
if cnt%2==0:
if x>=2 and y>=2:
num_100=2
elif y>=22:
num_100=0
elif x>=1 and y>=12:
num_100=1
else:
break
num_10=(220-100*num_100)//10
x-=num_100
y-=num_10
else:
if y>=22:
num_10=22
elif y>=12 and x>=1:
num_10=12
elif y>=2 and x>=2:
num_10=2
else:
break
num_100=(220-10*num_10)//100
x-=num_100
y-=num_10
cnt+=1
if cnt%2==0:
print("Hanako")
else:
print("Ciel")
|
1100
|
79_A. Bus Game
|
1100_33
|
O(1)
|
O(1)
|
x, y = map(int, input().split())
c = min(x // 2, y // 24)
x -= 2 * c
y -= 24 * c
c = min(x // 3, y // 14)
x -= 3 * c
y -= 14 * c
c = min(x // 4, y // 4)
x -= 4 * c
y -= 4 * c
c = min(x, y // 34)
x -= 1 * c
y -= 34 * c
c = y // 44
y -= 44 * c
if y >= 2 and 10 * x + y >= 22:
print('Ciel')
else:
print('Hanako')
|
1100
|
79_A. Bus Game
|
1100_34
| null | null |
x, y = map(int, input().split())
ciel = True
while True:
if ciel:
s = 0
while s + 100 <= 220 and x > 0:
x -= 1
s += 100
while s + 10 <= 220 and y > 0:
y -= 1
s += 10
if s != 220:
print('Hanako')
quit()
ciel = False
else:
if y >= 22:
y -= 22
elif y >= 12 and x >= 1:
y -= 12
x -= 1
elif y >= 2 and x >= 2:
y -= 2
x -= 2
else:
print('Ciel')
quit()
ciel = True
|
1100
|
79_A. Bus Game
|
1100_35
|
O(n)
|
O(1)
|
datos = input().split()
monedas_cien = int(datos[0])
monedas_diez = int(datos[1])
rondas_jugadas = min(monedas_cien // 2, monedas_diez // 24)
monedas_cien = monedas_cien - (rondas_jugadas*2)
monedas_diez = monedas_diez - (rondas_jugadas*24)
maneras_sacar_cien = [2,1,0]
maneras_sacar_diez = [2,12,22]
ganando = 'Hanako'
continua = True
i = 0
while continua:
if i % 2 == 0:
j = 0
while j<3:
if maneras_sacar_cien[j] <= monedas_cien and maneras_sacar_diez[j] <= monedas_diez:
monedas_cien = monedas_cien - maneras_sacar_cien[j]
monedas_diez = monedas_diez - maneras_sacar_diez[j]
ganando = 'Ciel'
break
j = j+1
if j == 3:
continua = False
break
else:
j = 0
while j<3:
if maneras_sacar_cien[2-j] <= monedas_cien and maneras_sacar_diez[2-j] <= monedas_diez:
monedas_cien = monedas_cien - maneras_sacar_cien[2-j]
monedas_diez = monedas_diez - maneras_sacar_diez[2-j]
ganando = 'Hanako'
break
j = j+1
if j == 3:
continua = False
break
i = i+1
print(ganando)
|
1100
|
79_A. Bus Game
|
1100_36
| null | null |
#Ya Hassan Mojtaba
x,y=map(int,input().split())
i=1
while 1:
if i%2==1:
if x>=2 and y>=2:
x-=2
y-=2
elif x==1 and y>=12:
x-=1
y-=12
elif y>=22:
y-=22
else:
print('Hanako')
exit()
else:
if y>=22:
y-=22
elif y>=12 and x>=1:
x-=1
y-=12
elif x>=2 and y>=2:
x-=2
y-=2
else:
print('Ciel')
exit()
i+=1
|
1100
|
79_A. Bus Game
|
1100_37
| null | null |
import sys
n,m=map(int, input().split())
while True:
if n*10+m<22 or m<2:
print("Hanako")
sys.exit()
if n>=2:
n-=2
m-=2
elif n==1:
n-=1
m-=12
else:
m-=22
if n*10+m<22 or m<2:
print("Ciel")
sys.exit()
if m>=22:
m-=22
elif m>=12:
n-=1
m-=12
else:
n-=2
m-=2
|
1100
|
79_A. Bus Game
|
1100_38
|
O(nlogn)
|
O(1)
|
x, y = map(int, input().split())
c=2
while True:
if c%2==0:
if x>=2 and y>=2:
c=c+1
x=x-2
y=y-2
continue
elif x>=1 and y>=12:
c=c+1
x=x-1
y=y-12
continue
elif x>=0 and y>=22:
c=c+1
y=y-22
continue
else:
print("Hanako")
break
if c%2==1:
if x>=0 and y>=22:
c=c+1
y=y-22
continue
elif x>=1 and y>=12:
c=c+1
x=x-1
y=y-12
continue
elif x>=2 and y>=2:
c=c+1
x=x-2
y=y-2
continue
else:
print("Ciel")
break
|
1100
|
79_A. Bus Game
|
1100_39
|
O(nlogn)
|
O(1)
|
x, y = map(int, input().split())
moves = 0
move = True
if x == 1000 and y == 1000: move = False
while move:
if moves % 2 == 0:
if x >= 2 and y >= 2:
moves += 1
x -= 2
y -= 2
elif x == 1 and y >= 12:
moves += 1
x -= 1
y -= 12
elif x == 0 and y >= 22:
moves += 1
y -= 22
else:
move = False
elif moves % 2 == 1:
if y >= 22:
moves += 1
y -= 22
elif x >= 1 and y >= 12:
moves += 1
x -= 1
y -= 12
elif x >= 2 and y >= 2:
moves += 1
x -= 2
y -= 2
else:
move = False
ans = 'Ciel' if moves % 2 == 1 else 'Hanako'
if x == 1000 and y == 1000:
print('Ciel')
else:
print(ans)
|
1100
|
79_A. Bus Game
|
1100_40
|
O(n)
|
O(1)
|
def readln(): return tuple(map(int, input().split()))
x, y = readln()
x *= 100
y *= 10
_ = 0
while x + y >= 220:
if _ == 0:
if x >= 200:
x -= 200
y -= 20
elif x == 100:
x -= 100
y -= 120
else:
y -= 220
else:
if y >= 220:
y -= 220
elif y >= 120:
y -= 120
x -= 100
else:
y -= 20
x -= 200
if x < 0 or y < 0:
break
_ = ( _ + 1) % 2
print('Hanako' if not _ else 'Ciel')
|
1100
|
79_A. Bus Game
|
1100_41
|
O(nlogn)
|
O(1)
|
x, y = map(int , input().split())
a = 0
while 1:
if a%2==0:
if x>=2 and y>=2:
x = x-2
y = y-2
elif x==1 and y>=12:
x = x-1
y = y-12
elif x==0 and y>=22:
x = 0
y = y-22
else:
break
else:
if y>=22:
y = y-22
elif x>=1 and 22>y>=12:
x = x-1
y = y-12
elif x>=2 and 12>y>=2:
x = x-2
y = y-2
else:
break
#print(x,y)
a = a+1
if a%2==1:
print("Ciel")
else:
print("Hanako")
|
1100
|
79_A. Bus Game
|
1100_42
|
O(nlogn)
|
O(1)
|
import bisect
from itertools import accumulate
import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
# ------------------- fast io --------------------
x,y=map(int,input().split())
sum=x*100+y*10
chance=2
while(True):
if chance%2==0:
if x>=2 and y>=2:
x-=2
y-=2
elif x>=1 and y>=12:
x-=1
y-=12
elif y>=22:
y-=22
else:
print("Hanako")
break
chance+=1
else:
if y>=22:
y-=22
elif x>=1 and y>=12:
x-=1
y-=12
elif x>=2 and y>=2:
x-=2
y-=2
else:
print("Ciel")
break;
chance+=1
|
1100
|
79_A. Bus Game
|
1100_43
| null | null |
x,y=map(int,input().split())
while True:
# Client's turn
if(x>=2 and y>=2):
x-=2
y-=2
elif(x>=1 and y>=12):
x-=1
y-=12
elif(x>=0 and y>=22):
y-=22
else:
print("Hanako")
exit()
# Hanako's turn
if(x>=0 and y>=22):
y-=22
elif(x>=1 and y>=12):
x-=1
y-=12
elif(x>=2 and y>=2):
y-=2
x-=2
else:
print("Ciel")
exit()
|
1100
|
79_A. Bus Game
|
1100_44
|
O(n)
|
O(1)
|
x, y = map(int, input().split())
turn = 0
res = ""
while 1:
if turn == 0:
if x >= 2 and y >= 2:
x-=2
y-=2
elif x == 1 and y >= 12:
x-=1
y-=12
elif x == 0 and y >= 22:
y-=22
else:
res = "Hanako"
break
else:
if y >= 22:
y-= 22
elif y >= 12 and x >= 1:
x-=1
y-=12
elif y >= 2 and x >= 2:
x-=2
y-=2
else:
res = "Ciel"
break
turn^=1
print(res)
|
1100
|
79_A. Bus Game
|
1100_45
|
O(nlogn)
|
O(1)
|
x,y = map(int,input().split())
turns = 0
while True:
if turns%2==0:
if x>=2 and y>=2:
x-=2
y-=2
turns+=1
elif x>=1 and y>=12:
x-=1
y-=12
turns+=1
elif y>=22:
y-=22
turns+=1
else:
break
else:
if y>=22:
y-=22
turns+=1
elif x>=1 and y>=12:
x-=1
y-=12
turns+=1
elif x>=2 and y>=2:
x-=2
y-=2
turns+=1
else:
break
if turns%2==1:
print("Ciel")
else:
print("Hanako")
|
1100
|
79_A. Bus Game
|
1100_46
| null | null |
def inp():
return map(int, input().split())
x, y = inp()
ceil, hanako = 1, 0
while (True):
if ceil:
if x >= 2 and y >= 2:
x -= 2
y -= 2
elif x == 1 and y >= 12:
x -= 1
y -= 12
elif x == 0 and y >= 22:
y -= 22
else:
exit(print('Hanako'))
ceil, hanako = 0, 1
else:
if y >= 22:
y -= 22
elif y >= 12 and x >= 1:
y -= 12
x -= 1
elif y >= 2 and x >= 2:
y -= 2
x -= 2
else:
exit(print('Ciel'))
hanako, ceil = 0, 1
|
1100
|
79_A. Bus Game
|
1100_47
|
O(nlogn)
|
O(1)
|
import math
import os
import random
import re
import sys
t=1
for qq in range(t):
x,y=(int(i) for i in input().split())
turn =0
while(True):
if turn%2==0 :
if x>=2 and y>=2:
x-=2
y-=2
elif x>=1 and y>=12:
x-=1
y-=12
elif y>=22:
y-=22
else:
print('Hanako')
break
else:
if y >= 22:
y -= 22
elif x>=1 and y>=12:
x-=1
y-=12
elif x>=2 and y>=2:
x-=2
y-=2
else:
print('Ciel')
break
turn+=1
|
1100
|
79_A. Bus Game
|
1100_48
|
O(n)
|
O(1)
|
x, y = map(int, input().split())
while True:
# Ciel prefers large coins.
#print('available: %d * 10, %d * 1' % (x, y))
a = min(2, x)
x -= a
b = min(22 - 10 * a, y)
y -= b
#print('Ciel takes %d * 10, %d * 1' % (a, b))
if 10 * a + b < 22:
print('Hanako')
break
# Hanako prefers small coins.
#print('available: %d * 10, %d * 1' % (x, y))
# Start by maximizing the number of large coins.
a = min(2, x)
x -= a
b = min(22 - 10 * a, y)
y -= b
if 10 * a + b < 22:
print('Ciel')
break
# Exchange large coins for small.
while a > 0 and y >= 10:
a -= 1
x += 1
y -= 10
#print('Hanako takes %d * 10, %d * 1' % (a, b))
|
1100
|
79_A. Bus Game
|
1100_49
| null | null |
x,y=map(int,input().strip().split())
# -2, -2
# -0, -22
# total, -2, -24
a = min(x//2, y//24)
x -= a*2
y -= a*24
while x and y:
tot = 220
while x > 0 and tot >= 100:
x -= 1
tot -= 100
while y > 0 and tot >= 10:
y -= 1
tot -= 10
if tot:
print("Hanako")
exit(0)
tot = 220
while y > 0 and tot >= 210:
y -= 1
tot -= 10
while y >= 10 and tot:
y -= 10
tot -= 100
while x > 0 and tot >= 100:
x -= 1
tot -= 100
if tot:
print("Ciel")
exit(0)
if x:
print("Hanako")
exit(0)
if not (y//22)%2:
print("Hanako")
else:
print("Ciel")
|
1100
|
79_A. Bus Game
|
1100_50
|
O(1)
|
O(1)
|
def f(a, b):
k = min(a, 2)
return a - k, b - 22 + 10 * k
def g(a, b):
if b < 2: return -1, -1
b -= 2
k = min(b // 10, 2)
return a - 2 + k, b - 10 * k
def main():
a, b = map(int, input().split())
k = min(a // 2, b // 24)
a -= k * 2
b -= 24 * k
while a > 0:
a, b = f(a, b)
if a < 0 or b < 0: return 0
a, b = g(a, b)
if a < 0 or b < 0: return 1
if a == 0: return (b // 22) % 2
print(['Hanako', 'Ciel'][main()])
|
1100
|
79_A. Bus Game
|
1100_51
|
O(n)
|
O(1)
|
x,y=map(int,input().split())
mauka=0
while 1:
if mauka==0:
if x>=2 and y>=2:
x=x-2
y=y-2
elif x>=1 and y>=12:
x=x-1
y=y-12
elif x==0 and y>=22:
y=y-22
else:
culprit=0
break
else:
if y>=22:
y=y-22
elif y>=12 and x>=1:
y=y-12
x=x-1
elif y>=2 and x>=2:
x=x-2
y=y-2
else:
culprit=1
break
# print(x,y)
mauka=1-mauka
if culprit:
print('Ciel')
else:
print('Hanako')
|
1100
|
79_A. Bus Game
|
1100_52
| null | null |
x,y=map(int,input().split())
Ceil=True
while True:
if Ceil:
if x>=2:
if y>=2:
x-=2; y-=2; Ceil=False
else:
print("Hanako"); exit()
elif x==1:
if y>=12:
x-=1; y-=12; Ceil=False
else:
print("Hanako"); exit()
else:
if y>=22:
y-=22; Ceil=False
else:
print("Hanako"); exit()
else:
if y>=22:
y-=22;Ceil=True
elif y>=12:
if x>=1:
x-=1;y-=12;Ceil=True
else:
print("Ciel"); exit()
elif y>=2:
if x>=2:
x-=2;y-=2;Ceil=True
else:
print("Ciel"); exit()
else:
print("Ciel"); exit()
|
1100
|
79_A. Bus Game
|
1100_53
|
O(nlogn)
|
O(1)
|
x, y = [int(x) for x in input().split()]
def even_move(x, y):
if x >= 2 and y >= 2:
return [True, x - 2, y - 2]
if x >= 1 and y >= 12:
return [True, x - 1, y - 12]
if y >= 22:
return [True, x, y - 22]
return [False, x, y]
def odd_move(x, y):
if y >= 22:
return [True, x, y - 22]
if x >= 1 and y >= 12:
return [True, x - 1, y - 12]
if x >= 2 and y >= 2:
return [True, x - 2, y - 2]
return [False, x, y]
def game(x, y):
even = 'Ciel'
odd = 'Hanako'
i = 0
while True:
if i % 2 == 0:
move = even_move(x, y)
if move[0]:
x = move[1]
y = move[2]
else:
return odd
else:
move = odd_move(x, y)
if move[0]:
x = move[1]
y = move[2]
else:
return even
i += 1
print(game(x, y))
|
1100
|
79_A. Bus Game
|
1100_54
|
O(nlogn)
|
O(1)
|
x,y = map(int, input().split())
t=0
while (1):
if t%2==0:
if x >= 2 and y >= 2:
x -= 2
y -= 2
elif x >= 1 and y >= 12:
x -= 1
y -= 1
elif (x == 0 and y >= 22):
y -= 22
else:
print("Hanako")
break
else:
if (y >= 22):
y -= 22
elif (x >= 1 and y >= 12):
x -= 1
y -= 12
elif (x >= 2 and y >= 2):
x -= 2
y -= 2
else:
print("Ciel")
break
t+=1
|
1100
|
79_A. Bus Game
|
1100_55
|
O(1)
|
O(1)
|
import math
import queue
from itertools import permutations
def win(x,y):
if x==0:
k=y//22
if k%2==1:
return 1
else:
return 2
elif x==1:
if y<12:
return 2
k=1+(y-12)//22
if k%2==1:
return 1
else:
return 2
elif y<24:
if y<2:
return 2
elif ((x-2)>=1) and ((y-2)>=12):
return win(x-3,y-14)
elif (x-2)>=2 and (y-2)>=2:
return win(x-4,y-4)
else:
return 1
k=min(x//2,y//24)
x-=2*k
y-=24*k
return win(x,y)
m,n=map(int, input().split())
if win(m,n)==1:
print("Ciel")
else:
print("Hanako")
|
1100
|
79_A. Bus Game
|
1100_56
| null | null |
import sys
import math
x, y = [int(x) for x in (sys.stdin.readline()).split()]
while(1):
if(x >= 2 and y >= 2):
x -= 2
y -= 2
elif(x >= 1 and y >= 12):
x -= 1
y -= 1
elif(x == 0 and y >= 22):
y -= 22
else:
print("Hanako")
exit()
if(y >= 22):
y -= 22
elif(x >= 1 and y >= 12):
x -= 1
y -= 12
elif(x >= 2 and y >= 2):
x -= 2
y -= 2
else:
print("Ciel")
exit()
|
1100
|
79_A. Bus Game
|
1100_57
|
O(n)
|
O(1)
|
x, y = map(int, input().split())
m = 0
while True:
if m:
if y<2:
b = 0
else:
b = max(k for k in (2,12,22) if k<=y)
a = min(x, (220-10*b)//100)
else:
a = min(2,x)
b = min(y, (220-100*a)//10)
if 100*a+10*b < 220:
print('Ciel' if m else 'Hanako')
break
x -= a
y -= b
m = 1-m
|
1100
|
79_A. Bus Game
|
1100_58
|
O(n)
|
O(1)
|
x,y=map(int,input().split())
t=1
o=1
while o:
if t:
if x>=2 and y>=2:
x-=2
y-=2
elif x>=1 and y>=12:
x-=1
y-=12
elif y>=22:y-=22
else:o=0
else:
if y>=22:y-=22
elif x>=1 and y>=12:
x-=1
y-=12
elif x>=2 and y>=2:
x-=2
y-=2
else:o=0
t=1-t
print("Ciel"if t else"Hanako")
|
1100
|
79_A. Bus Game
|
1100_59
| null | null |
import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import add
from itertools import accumulate
inf = float('inf')
# input = sys.stdin.readline
flush = lambda : sys.stdout.flush
comb = lambda x , y : (factorial(x) // factorial(y)) // factorial(x - y)
#inputs
# ip = lambda : input().rstrip()
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
a , b =r()
c = 1
while a or b:
x = 220
while a and x>=100:
a-=1
x-=100
while b and x:
b-=1
x-=10
if c%2==0:
if b>9:
a+=1
b-=10
if b>9:
a+=1
b-=10
if x:
print("Hanako" if c%2 else "Ciel")
exit()
c+=1
print("Hanako" if c%2 else "Ciel")
|
1101
|
867_A. Between the Offices
|
1101_0
|
O(1)
|
O(1)
|
print((lambda s: 'YES' if s[1][0] == 'S' and s[1][-1] == 'F' else 'NO')((input(), input().strip())))
|
1101
|
867_A. Between the Offices
|
1101_1
|
O(n)
|
O(1)
|
n = int(input())
shed = str(input())
ToS = 0
ToF= 0
for i in range(len(shed)-1):
if(shed[i] == 'S' and shed[i+1] == 'F'):
ToF += 1
if(shed[i] == 'F' and shed[i+1] == 'S'):
ToS += 1
if(ToF > ToS):
print('YES')
else:
print('NO')
|
1101
|
867_A. Between the Offices
|
1101_2
|
O(n)
|
O(1)
|
n = int(input())
string = input()
counter_s = 0
counter_f = 0
for i in range(1, len(string)):
if string[i] == "S" and string[i - 1] == "F":
counter_f += 1
elif string[i] == "F" and string[i - 1] == "S":
counter_s += 1
print("YES" if counter_s > counter_f else "NO")
|
1101
|
867_A. Between the Offices
|
1101_3
|
O(n)
|
O(1)
|
n = int(input())
s = input()
kf = 0
ks = 0
temp = s[0]
for i in range(1, len(s)):
if (temp != s[i]) and (s[i] == 'F'):
temp = s[i]
kf += 1
elif (temp != s[i]) and (s[i] == 'S'):
temp = s[i]
ks += 1
if kf > ks:
print('YES')
else:
print('NO')
|
1101
|
867_A. Between the Offices
|
1101_4
|
O(n)
|
O(1)
|
n=int(input())
s=input()
s2f=f2s=0
for i in range(n-1):
if s[i:i+2] == 'SF':
s2f+=1
elif s[i:i+2] == 'FS':
f2s+=1
print('YES' if s2f>f2s else 'NO')
|
1101
|
867_A. Between the Offices
|
1101_5
| null | null |
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7
# ここから書き始める
n = int(input())
s = input()
cnt1 = 0
cnt2 = 0
i = 1
while i < n:
if s[i] == "F" and s[i - 1] == "S":
cnt1 += 1
elif s[i] == "S" and s[i - 1] == "F":
cnt2 += 1
i += 1
if cnt1 > cnt2:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_6
|
O(n)
|
O(1)
|
n, str = int(input()), input()
fs, sf = 0, 0
for i in range(str.__len__() - 1):
if str[i: i + 2] == "FS":
fs += 1
elif str[i: i + 2] == "SF":
sf += 1
print("yes" if sf > fs else "no")
|
1101
|
867_A. Between the Offices
|
1101_7
|
O(n)
|
O(1)
|
n=int(input())
a=input()
s=0
f=0
for i in range(n-1):
if a[i]+a[i+1]=='SF':
f+=1
if a[i]+a[i+1]=='FS':
s+=1
if f>s:
print('YES')
else:
print('NO')
|
1101
|
867_A. Between the Offices
|
1101_8
|
O(n)
|
O(n)
|
#Wrong Substraction
# n,k= input().split()
# n= int(n)
# k = int(k)
# for i in range(k):
# if(n%10==0):
# n=n/10
# else:
# n-=1
# n=int(n)
# print(n)
#Easy Question
# n = int(input())
# h = 0
# for i in range(n):
# k=int(input())
# if k == 0 or 1 :
# if k == 0 :
# pass
# else:
# h = 1
# if k == 0 or 1 :
# if h == 1 :
# print("HARD")
# else:
# print("EASY")
# Bear and Big Brother
# a ,b =input().split()
# a=int(a)
# b=int(b)
# count = 0
# if a <= b:
# while a<=b:
# a*=3
# b*=2
# count+=1
# print(int(count))
#Anton and Polyhedrons
# n = int(input())
# count = 0
# for i in range(n):
# s=input()
# if(s == 'Tetrahedron'):
# count+=4
# elif(s== 'Cube'):
# count+=6
# elif(s=='Octahedron'):
# count+=8
# elif(s=='Dodecahedron'):
# count+=12
# elif(s=='Icosahedron'):
# count+=20
# else:
# count+=0
# print(int(count))
#Hit the Lottery
# n = int(input())
# count = 0
# while (n!=0):
# if(n>=100):
# n-=100
# count+=1
# continue
# if(20<=n):
# n-=20
# count+=1
# continue
# if(10<=n):
# n-=10
# count+=1
# continue
# if(5<=n):
# n-=5
# count+=1
# continue
# if(1<=n):
# n-=1
# count+=1
# continue
# print(int(count))
#Restoring Three Numbers
# #include<bits/stdc++.h>
# using namespace std;
# int main()
# {
# int a[4],ar,b,c,i;
# while(cin>>a[0]>>a[1]>>a[2]>>a[3])
# {
# sort(a,a+4);
# ar=a[3]-a[0];
# b=a[3]-a[2];
# c=a[3]-a[1];
# cout<<ar<<" "<<b<<" "<<c<<endl;
# }
# }
#Gennady and a Card Game
# c = 0
# n = input()
# for i in range(5):
# i1 = input()
# if (n[0]==i1[0] or n[1]==i1[1]):
# c+=1
# if(c>0):
# print("YES",end=" ")
# else:
# print("NO",end=" ")
#Fafa and his Company
# #include<bits/stdc++.h>
# using namespace std;
# int main()
# {
# int n,i,c=0,h;
# cin >> n;
# h=n/2;
# for(i=1;i<=h;i++)
# {
# if(n%i == 0)
# {
# c++;
# }
# }
# cout << c;
# }
#Vus the Cossack and a Contest
# n,m,k= input().split(" ")
# n=int(n)
# m=int(m)
# k=int(k)
# if (n<=m and n<=k):
# print("Yes")
# else:
# print("No")
#Cards
# n = int(input("enter n: "))
# zero= 0
# one = 0
# s = input("enter the string: ")
# for i in range(len(s)):
# if(s[i]=='z'):
# --zero
# if(s[i]=='n'):
# --one
# while(one-1):
# break
# while(zero-1):
# print("0")
#New Year and Naming
# #include<bits/stdc++.h>
# using namespace std;
# int main()
# {
# int m,n,i,q,x;
# string sn[20],sm[20];
# std::cin >> n;
# std::cin >> m;
# for(i=0;i<n;i++)
# {
# std::cin >> sn[i];
# }
# for(i=0;i<m;i++)
# {
# std::cin >> sm[i];
# }
# std::cin >> q;
# while (q--)
# {
# std::cin >> x;
# x--;
# std::cout << sn[x%n]+sm[x%m]<<endl;
# }
# }
#Between the Offices
n = int(input())
s= input()
cs=0
cns=0
s=list(s)
if(n==len(s)):
for i,j in zip(range(0,len(s)-1),range(1,len(s))):
if(s[i]=='S'):
if(s[j]=='F'):
cs+=1
else:
continue
elif(s[i]=='F'):
if(s[j] == 'S'):
cns+=1
else:
continue
if(cs>cns):
print("YES")
elif(cns>=cs):
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_9
|
O(nlogn)
|
O(1)
|
read = lambda:map(int, input().split())
n = int(input())
f = input()
rt = 0
for i in range(n - 1):
if f[i] == "S" and f[i + 1] == "F":
rt += 1
elif f[i] == "F" and f[i + 1] == "S":
rt -= 1
if (rt > 0):
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_10
|
O(1)
|
O(1)
|
def main():
n = int(input().strip())
flights = input().strip()
sfflights = 0
fsflights = 0
prev = flights[0]
for i in range(1, n):
curr = flights[i]
if prev == 'F' and curr == 'S':
fsflights += 1
elif prev == 'S' and curr == 'F':
sfflights += 1
prev = curr
if sfflights > fsflights:
print("YES")
else:
print("NO")
if __name__ == '__main__':
main()
|
1101
|
867_A. Between the Offices
|
1101_11
|
O(n)
|
O(1)
|
n=int(input())
string=input()
san=string.count('SF')
fran=string.count('FS')
if(san>fran):
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_12
|
O(1)
|
O(1)
|
def flight(s):
letter = ''
countF = 0
countS = 0
locations = [i for i in s]
for i in range(len(locations)):
if i == 0:
letter = locations[i]
elif locations[i] == 'F' and letter != locations[i]:
countS += 1
letter = locations[i]
elif locations[i] == 'S' and letter != locations[i]:
countF += 1
letter = locations[i]
if countS > countF:
return 'YES'
return 'NO'
if __name__ == "__main__":
n = input().strip()
s = list(map(str, input().strip()))
print(flight(s))
|
1101
|
867_A. Between the Offices
|
1101_13
|
O(n+m)
|
O(n)
|
n = int(input())
d = [i for i in input()]
seattle_sanfran = 0
sanfran_seattle = 0
s = len(d)
for j in range(n):
if j == s - 1:
break
if d[j] == 'S':
if d[j+1] == 'F':
seattle_sanfran += 1
elif d[j] == 'F':
if d[j+1] == 'S':
sanfran_seattle += 1
if seattle_sanfran > sanfran_seattle:
print('YES')
else:
print('NO')
|
1101
|
867_A. Between the Offices
|
1101_14
|
O(1)
|
O(1)
|
input()
a=input()
print('NYOE S'[a[0]=='S'and a[-1]=='F'::2])
|
1101
|
867_A. Between the Offices
|
1101_15
|
O(nlogn)
|
O(1)
|
sf = 0
fs = 0
n = int(input())
s = input()
for x in range(n-1):
if s[x] == "F" and s[x+1] == "S":
fs += 1
elif s[x] == "S" and s[x+1] == "F":
sf += 1
if sf > fs:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_16
|
O(n+m)
|
O(n)
|
n=int(input())
S=input()
S=list(S)
sf=0
fs=0
for i,s in enumerate(S):
if i+1<n:
if (S[i]=='s' or S[i]=='S')and(S[i+1]=='f' or S[i+1]=='F'):
sf+=1
else:
if i+1<n:
if (S[i]=='f' or S[i]=='F')and(S[i+1]=='s'or S[i+1]=='S'):
fs+=1
if (sf>fs):
print('YES')
else:
print('NO')
|
1101
|
867_A. Between the Offices
|
1101_17
|
O(n)
|
O(1)
|
input()
s = input()
print('YES' if s.count('SF') > s.count('FS') else 'NO')
|
1101
|
867_A. Between the Offices
|
1101_18
|
O(n)
|
O(1)
|
k=int(input())
a=input()
c=a.count("SF")
d=a.count("FS")
if(c>d):
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_19
|
O(nlogn)
|
O(1)
|
n=int(input())
s=0
f=0
a=str(input())
for i in range (1,n) :
if a[i-1]=="S" and a[i]=="F":
s=s+1
if a[i-1]=="F" and a[i]=="S":
f=f+1
if s>f:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_20
|
O(nlogn)
|
O(n)
|
n = int(input())
days = input()
start = days[0]
sf = 0
fs = 0
for i in range(1,n):
if start != days[i]:
if start == 'S':
sf += 1
else:
fs += 1
start = days[i]
print('YES' if sf > fs else 'NO')
|
1101
|
867_A. Between the Offices
|
1101_21
|
O(n)
|
O(1)
|
n = int(input())
x = input()
a = 0
b = 0
for i in range(len(x)):
if i == len(x) - 1:
break
elif x[i] == "F" and x[i+1] == "S" :
b += 1
elif x[i] == "S" and x[i+1] == "F" :
a += 1
if a > b:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_22
|
O(n)
|
O(1)
|
n = int(input())
a = ''
ans = count=0
a = str(input())
for j in range(1, len(a)):
if a[j-1]=='S' and a[j]=='F' :
ans+=1
if a[j-1]=='F' and a[j]=='S' :
count+=1
if ans>count:
print('YES')
else:
print('NO')
|
1101
|
867_A. Between the Offices
|
1101_23
|
O(n)
|
O(1)
|
n = int(input())
word = input()
if word.count("SF") > word.count("FS"):
print ("YES")
else:
print ("NO")
|
1101
|
867_A. Between the Offices
|
1101_24
|
O(n)
|
O(1)
|
a = 'SF'
b = 'FS'
df = int(input())
n = input()
c = n.count(a)
d = n.count(b)
if c > d:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_25
|
O(nlogn)
|
O(n)
|
n=int(input())
a=list(input())
s=f=0
for i in range(n-1):
if((a[i]=='S')and(a[i+1]=='F')):
s+=1
if((a[i]=='F')and(a[i+1]=='S')):
f+=1
if(s>f):
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_26
|
O(nlogn)
|
O(n)
|
n = int(input())
a = input()
counter = 0
count = 0
for i in range(n - 1):
if a[i] == "S" and a[i + 1] == "F":
counter += 1
if a[i] == "F" and a[i + 1] == "S":
count += 1
if counter > count:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_27
|
O(n)
|
O(1)
|
input()
x = input()
if (x.count('SF') > x.count('FS')):
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_28
|
O(n)
|
O(1)
|
d=int(input())
n=input()
c=0
d=0
for i in range(len(n)-1) :
if n[i]=="S" and n[i+1]=="F" :
c=c+1
elif n[i]=="F" and n[i+1]=="S" :
d=d+1
if c>d :
print("YES")
else :
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_29
|
O(nlogn)
|
O(1)
|
n=int(input())
s=input()
count=0
num=0
for i in range(n-1):
if s[i]=="S" and s[i+1]=="F":
count+=1
elif s[i]=="F" and s[i+1]=="S":
num+=1
if count>num:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_30
|
O(nlogn)
|
O(1)
|
n=int(input())
s=input()
x=0
y=0
for i in range(n-1):
if s[i]=='S' and s[i+1]=='F':
x+=1
elif s[i]=='F' and s[i+1]=='S':
y+=1
print('YES' if x>y else 'NO')
|
1101
|
867_A. Between the Offices
|
1101_31
|
O(n)
|
O(1)
|
input()
a = input()
print('YES' if a.count('SF') > a.count('FS') else 'NO')
|
1101
|
867_A. Between the Offices
|
1101_32
|
O(n)
|
O(n)
|
useless = int(input())
data = list(input().strip().upper())
seatle, francisco, count = 0, 0, 0
while count < useless - 1:
if data[count] == "S" and data[count + 1] == "F":
seatle += 1
elif data[count] == "F" and data[count + 1] == "S":
francisco += 1
count += 1
if seatle > francisco:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_33
|
O(nlogn)
|
O(n)
|
n = int(input());last="";f=s=0
l=list(input())
for i in range(n):
x=l[i]
if i==0:
if x=="S":
s-=1
else:
f-=1
if x != last and x=="S":
s+=1
elif x!=last and x=="F":
f+=1
last=x
print(["NO","YES"][f>s])
|
1101
|
867_A. Between the Offices
|
1101_34
|
O(nlogn)
|
O(1)
|
numOfDays=int(input())
travelD=input()
counterSF=0
counterFS=0
for i in range(numOfDays-1):
if travelD[i]=="S" and travelD[i+1]=="F":
counterSF += 1
if travelD[i] == "F" and travelD[i + 1] == "S":
counterFS += 1
if counterSF>counterFS:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_35
|
O(1)
|
O(1)
|
def solve():
n_days = input()
cities = input()
last_city = cities[0]
out = 0
for city in cities[1:]:
if city != last_city:
if city == "F":
out += 1
else:
out -= 1
last_city = city
if out > 0:
print("YES")
else:
print("NO")
if __name__ == "__main__":
while True:
try:
solve()
except:
break
|
1101
|
867_A. Between the Offices
|
1101_36
|
O(nlogn)
|
O(n)
|
n = int(input())
s = list(str(input()))
fToS = 0
sToF = 0
for i in range(n-1):
if s[i] == "F" and s[i+1] == "S":
fToS+=1
elif s[i] == "S" and s[i+1] == "F":
sToF+=1
if sToF > fToS:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_37
|
O(nlogn)
|
O(n)
|
a = int(input())
b = input()
b = list(b)
e = int()
f = int()
for x in range(a):
if x < (a-1):
if b[x] == b[x+1]:
pass
elif b[x] < b[x+1]:
f = f + 1
elif b[x] > b[x+1]:
e = e + 1
if e > f:
print("Yes")
else:
print("No")
|
1101
|
867_A. Between the Offices
|
1101_38
|
O(nlogn)
|
O(1)
|
n = int(input())
s = input()
good = 0
bad = 0
for i in range(1, n):
if (s[i] == 'F') and (s[i - 1] == 'S'):
good += 1
elif (s[i] == 'S') and (s[i - 1] == 'F'):
bad += 1
if good > bad:
print("YES")
else:
print("NO")
|
1101
|
867_A. Between the Offices
|
1101_39
|
O(n)
|
O(1)
|
numDays = int(input())
flightInfo = input()
seattle_to_sf = 0
sf_to_seattle = 0
for i in range(1, len(flightInfo)):
if flightInfo[i] == 'S' and flightInfo[i - 1] == 'F':
sf_to_seattle += 1
elif flightInfo[i] == 'F' and flightInfo[i - 1] == 'S':
seattle_to_sf += 1
if seattle_to_sf > sf_to_seattle:
print("YES")
else:
print("NO")
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 14