s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s950322947
p00710
u399892098
1491797599
Python
Python
py
Accepted
40
6172
469
while True: n,r = map(int,raw_input().split()) if(n == 0 and r == 0): break li = [] for i in xrange(1,n+1): li.append(i) for i in xrange(r): temp_lis1 = [] p,c = map(int,raw_input().split()) if(c == 1): temp_lis1.append(li[n-p]) del(li[...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,895
s737112438
p00710
u546285759
1492153931
Python
Python3
py
Accepted
60
7540
266
while True: n, r = map(int, input().split()) if n == 0: break cards = [i+1 for i in range(n)][::-1] for _ in range(r): p, c = map(int, input().split()) cards = cards[p-1:p+c-1] + cards[:p-1] + cards[p+c-1:] print(cards[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,896
s136164157
p00710
u724963150
1496516464
Python
Python3
py
Accepted
80
7620
301
while True: a=[int(num)for num in input().split(' ')] n=a[0] if n==0:break hanafuda=[i+1 for i in range(n)] for i in range(a[1]): b=[int(num)for num in input().split(' ')] for j in range(b[1]):hanafuda.append(hanafuda.pop(n-(b[0]+b[1])+1)) print(hanafuda.pop())
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,897
s938805262
p00710
u650459696
1497195171
Python
Python3
py
Accepted
60
7536
272
while True: n, r = map(int, input().split()) if n == 0: break card = list(range(n, 0, -1)) for i in range(r): p, c = map(int, input().split()) t = card[p-1:p+c-1] del(card[p-1:p+c-1]) card[0:0] = t print(card[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,898
s392634933
p00710
u347385753
1498518088
Python
Python3
py
Accepted
80
7728
303
while 1: count, times = [int(a) for a in input().split()] hanahuda = [i+1 for i in range(count)] if count == times == 0:break for i in [0]*times: p,c = [int(i) for i in input().split()] for i in [0]*c:hanahuda.append(hanahuda.pop(count-(p+c)+1)) print(hanahuda.pop())
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,899
s502205823
p00710
u858560358
1499330476
Python
Python
py
Accepted
30
6256
393
def solve_testcase(): n, r = map(int, raw_input().split()) if (n, r) == (0, 0): return 1 cards = range(n, 0, -1) for i in range(r): p, c = map(int, raw_input().split()) cards[:c], cards[c:p+c] = cards[p-1:p+c], cards[:p-1] print cards[0] return 0 def main(): while ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,900
s447003674
p00710
u659034691
1503603848
Python
Python3
py
Accepted
90
7616
385
#hanafuda N,r=(int(i) for i in input().split()) while N!=0 or r!=0: H=[int(N-i) for i in range(N)] for i in range(r): p,c=(int(i) for i in input().split()) T=[] # print(H) for j in range(p-1,p+c-1): # print("T") T.append(H[p-1]) H.pop(p-1) ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,901
s567570134
p00710
u741801763
1505996028
Python
Python3
py
Accepted
60
7736
477
if __name__ == "__main__": while True: n,r=list(map(int,input().strip().split())) if n == 0 and r ==0 :break cards = [i for i in range(1,n + 1)] pset = [] cset = [] for j in range(r): p,c = list(map(int,input().strip().split())) pset = cards[n-...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,902
s144201910
p00710
u724963150
1506096113
Python
Python3
py
Accepted
60
7616
287
while True: n,r=[int(s)for s in input().split(" ")] if n==r==0:break ops=[[int(s)for s in input().split(" ")]for i in range(r)] cd=[n-i for i in range(n)] for op in ops: p,c=op l=cd[p-1:p+c-1] del cd[p-1:p+c-1] cd=l+cd print(cd[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,903
s294043598
p00710
u947762778
1507567233
Python
Python3
py
Accepted
60
7588
280
while True: n, r = map(int, input().split()) if n + r < 1: break mountain = list(range(n, 0, -1)) for i in range(r): p, c = map(int, input().split()) mountain = mountain[p-1:p-1+c] + mountain[0:p-1] + mountain[p-1+c:] print(mountain[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,904
s345076208
p00710
u506554532
1512814129
Python
Python3
py
Accepted
50
5616
253
while True: n,r = map(int,input().split()) if n == r == 0: break cards = [n-i for i in range(n)] for i in range(r): p,c = map(int,input().split()) cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:] print(cards[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,905
s562379527
p00710
u489876484
1517591038
Python
Python3
py
Accepted
60
5628
356
while True: n, r = list(map(lambda x: int(x), input().split(" "))) if n == 0 and r == 0: break cards = [i for i in range(1,n+1)] cards = cards[::-1] for i in range(r): p, c = list(map(lambda x: int(x), input().split(" "))) p -= 1 cards = cards[p:p+c] + cards[0:p] + c...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,906
s649090254
p00710
u963883732
1518517599
Python
Python3
py
Accepted
70
5620
371
while True: l = input() L = l.split() for i in range(len(L)): L[i] = int(L[i]) if L[0] == 0: break a = [L[0]-number for number in range(L[0])] for j in range(L[1]): r = input() R = r.split() for k in range(len(R)): R[k] = int(R[k]) b = [] b += a[R[0]-1:R[0]+R[1]-1] b += a[:R[0]-1] b += a[R[0...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,907
s960987107
p00710
u646461156
1521265743
Python
Python3
py
Accepted
50
5616
269
def main(): while True: n,r=map(int,input().split()) if n==0 and r==0: break ls=list(range(n,0,-1)) for i in range(r): p,c=map(int,input().split()) p-=1 tmp=ls[p:p+c] del ls[p:p+c] ls=tmp+ls print(ls[0]) if __name__=="__main__": main()
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,908
s615648698
p00710
u146816547
1523717991
Python
Python
py
Accepted
30
4648
288
while True: n, r = map(int, raw_input().split()) if n == 0 and r == 0: break Cards = [i for i in range(n, 0, -1)] for i in range(r): p, c = map(int, raw_input().split()) Cards = Cards[p-1:p-1+c] + Cards[:p-1] + Cards[p-1+c:] print Cards[0]
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,909
s768787303
p00710
u146816547
1523718116
Python
Python
py
Accepted
20
4648
276
while True: n, r = map(int, raw_input().split()) if n == 0 and r == 0: break Cards = range(n, 0, -1) for i in range(r): p, c = map(int, raw_input().split()) Cards = Cards[p-1:p-1+c] + Cards[:p-1] + Cards[p-1+c:] print Cards[0]
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,910
s871738583
p00710
u878596989
1523870309
Python
Python3
py
Accepted
90
5620
587
temp = True i = 0 N = [] M = [] while True: p,c = map(int, input().strip().split(' ')) if p == 0 and c == 0: break if temp: n = p r = c for j in range(n): N.append(n-j) temp = False else: for j in range(c): M.append(N[p+j-1]) ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,911
s096068339
p00710
u023471147
1526568815
Python
Python3
py
Accepted
50
5620
285
while True: n, r = map(int, input().split()); if n == 0 and r == 0: break deck = [n - i for i in range(n)] for i in range(r): p, c = map(int, input().split()) deck = deck[p - 1 : p + c - 1] + deck[:p - 1] + deck[p + c - 1:] print(deck[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,912
s211043750
p00710
u584093205
1526728230
Python
Python3
py
Accepted
60
5620
240
while(1): n, r = map(int, input().split()) if n == r == 0: break N = [n-i for i in range(n)] for i in range(r): p, c = map(int, input().split()) N = N[p-1:p-1+c] + N[:p-1] + N[p-1+c:] print(N[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,913
s137610528
p00710
u925259339
1527154290
Python
Python3
py
Accepted
50
5636
464
def main(): ans = [] while True: n, r = map(int, input().split()) if n == 0 and r == 0: break cards = [] for i in range(n): cards.append(i+1) cards = cards[::-1] for i in range(r): p, c = map(int, input().split()) ca...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,914
s071634955
p00710
u011621222
1527657348
Python
Python3
py
Accepted
50
5620
346
while(True): n, r = map(int, input().split()) if n == 0 and r == 0: exit() ope = [list(map(int, input().split())) for _ in range(r)] d = [n-i for i in range(n)] for i in range(r): tv = d[ope[i][0]-1:ope[i][0]-1+ope[i][1]] to = d[:ope[i][0]-1] + d[ope[i][0]-1+ope[i][1]:] d =...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,915
s459021419
p00710
u509278866
1527821351
Python
Python3
py
Accepted
80
9068
880
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**3 eps = 1.0 / 10**10 mod = 10**9+7 def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF():...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,916
s814236042
p00710
u572046143
1527868507
Python
Python3
py
Accepted
60
5616
385
while True: n, r = [int(s) for s in input().strip().split()] if n == 0 and r == 0: break cards = list(range(1, n+1)) cards.reverse() for _ in range(r): p, c = [int(s) for s in input().strip().split()] part1 = cards[0:p-1] part2 = cards[p-1:p-1+c] cards[0:...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,917
s270854714
p00710
u316584871
1529837249
Python
Python3
py
Accepted
60
5616
321
n , r = map(int, input().split()) while(n != 0 or r != 0): deck = [] for i in range(n): deck.append(i+1) deck.reverse() for i in range(r): p, c = map(int, input().split()) deck[:p + c -1] = deck[p-1:p+c-1] + deck[:p-1] print(deck[0]) n , r = map(int, input().split()) ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,918
s743111851
p00710
u136916346
1529905776
Python
Python3
py
Accepted
60
5612
214
while 1: n,r=list(map(int,input().split())) if not n and not r:break l=list(range(1,n+1))[::-1] for _ in range(r): p,c=list(map(int,input().split())) l=l[p-1:p-1+c]+l[0:p-1]+l[p-1+c:] print(l[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,919
s221772532
p00710
u352394527
1530347195
Python
Python3
py
Accepted
50
5616
243
while True: n, r = map(int, input().split()) if n == 0: break lst = [n - i for i in range(n)] for _ in range(r): p, c = map(int, input().split()) lst = lst[p - 1:p - 1 + c] + lst[:p - 1] + lst[p - 1 + c:] print(lst[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,920
s715691649
p00710
u500292616
1530624402
Python
Python3
py
Accepted
60
5620
421
n=1 r=1 while n !=0 and r!=0: n,r=input().split() n,r=int(n),int(r) card= [[int(i) for i in input().split()] for i in range(r)] yama= list(range(n,0,-1)) if n ==0 and r==0: break for i in range(r): p=card[i][0] c=card[i][1] x=yama[:p-1] y=yama[p-1:p...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,921
s635118434
p00710
u779627195
1352645163
Python
Python
py
Accepted
40
4224
410
while 1: n,r = map(int, raw_input().split()) if n == 0 and r == 0: break lib = range(n, 0, -1) #print lib for i in xrange(r): temp = [] p,c = map(int, raw_input().split()) for j in xrange(c): temp.append(lib....
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,922
s622818055
p00710
u109084363
1358013607
Python
Python
py
Accepted
20
4244
619
import sys while True: n, r = map(int, sys.stdin.readline().split()) if n == 0 and r == 0: break shuffle = [] for i in xrange(r): shuffle.append(map(int, sys.stdin.readline().split())) shuffle.reverse() pile = range(n) for s in shuffle: pile[s[0] + s[1] - 1:s[0] + s...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,923
s527309178
p00710
u104911888
1369121861
Python
Python
py
Accepted
30
4224
212
while True: n,r=map(int,raw_input().split()) if n==r==0:break L=range(1,n+1)[::-1] for i in range(r): p,c=map(int,raw_input().split()) p-=1 L=L[p:p+c]+L[:p]+L[p+c:] print L[0]
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,924
s310956011
p00710
u633068244
1399534798
Python
Python
py
Accepted
30
4204
209
while 1: n,r = map(int,raw_input().split()) if n == 0: break card = range(n,0,-1) for i in range(r): p,c = map(int,raw_input().split()) card = card[p-1:p-1+c] + card[:p-1] + card[p-1+c:] print card[0]
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,925
s821773986
p00710
u836923362
1595600100
Python
Python3
py
Accepted
50
5616
415
def shuffle(cards): index,cut_num = map(int,input().split()) pop = cards[index-1 :index + cut_num-1 ] del cards[index-1:index + cut_num-1] return pop + cards while True: num_card,challange = map(int,input().split()) if num_card == 0 and challange == 0: break cards = list(reversed(range...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,926
s212916597
p00710
u060839454
1594395838
Python
Python3
py
Accepted
40
5720
456
import sys import math input = sys.stdin.readline ## n, r = input().rstrip().split() n, r = int(n), int(r) while n + r > 0: yama = list(range(1, n + 1))[::-1] for _ in range(r): p, c = input().rstrip().split() p, c = int(p), int(c) top = yama[:p - 1] mid = yama[p - 1:p - 1 + c] ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,927
s989475634
p00710
u057189799
1594165381
Python
Python3
py
Accepted
50
5620
338
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break cards = [i + 1 for i in range(n)] cards.reverse() for _ in range(r): p, c = map(int, input().split()) new_cards = cards[p - 1 :p - 1 + c] + cards[0:p - 1] + cards[p - 1 + c:] cards = new_cards ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,928
s576542628
p00710
u489396453
1592575013
Python
Python3
py
Accepted
80
5628
914
# encoding: utf-8 def create_deck(deck_size): deck = [] for i in range(0,deck_size): deck.append(i+1) return deck def shuffle_deck(deck, start, cut_size): after = [] cut_cards = [] b = len(deck) - cut_size - start for i in range(0,len(deck)): if b >= i: after.app...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,929
s232091543
p00710
u921537862
1587988966
Python
Python3
py
Accepted
60
5620
453
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) def main(): while True: n,r = map(int,input().split()) if n == 0: return ans = list(range(n,0,-1)) for _ in range(r): p,c = map(int,input().split()) ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,930
s442363654
p00710
u206124123
1587284613
Python
Python3
py
Accepted
60
5620
1,100
class Deck: def __init__(self, card_num): self.deck_list = self.make_deck(card_num) def make_deck(self, card_num): deck_list = [None] * card_num order = 0 for i in reversed(range(1, card_num + 1)): deck_list[order] = i order += 1 return deck_list ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,931
s585376675
p00710
u925259339
1584872439
Python
Python3
py
Accepted
60
5620
300
while (True): n, r = map(lambda i: int(i), input().split()) if n == 0: break inds = [i for i in reversed(range(1, n+1))] for i in range(r): p, c = map(lambda j: int(j), input().split()) inds = inds[p-1:p-1+c] + inds[:p-1] + inds[p-1+c:] print(inds[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,932
s598514878
p00710
u975129011
1580563794
Python
Python3
py
Accepted
60
5612
341
while 1: n,r = map(int,input().split()) if n == 0 and r == 0: break lists = list(range(1,n+1)) lists.sort() lists.reverse() for i in range(r): p,c = map(int,input().split()) tmp = lists[p-1:(p-1)+c] lists[p-1:(p-1)+c] = [] lists = tmp + lists pr...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,933
s024141390
p00710
u821608651
1580205146
Python
Python3
py
Accepted
50
6088
951
import sys sys.setrecursionlimit(10 ** 6) from bisect import * from collections import * from heapq import * int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def SI(): return sys.stdin.readline()[:-1] def MI(): return map(int, sys.stdin.readline().split()) def...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,934
s511544850
p00710
u483930210
1579230819
Python
Python3
py
Accepted
70
5624
225
while 1: n, r=map(int, input().split()) if n==0: break a=[n-i for i in range(n)] for _ in range(r): p, c=map(int, input().split()) a=a[p-1:p-1+c] + a[0:p-1] + a[p-1+c:] print(a[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,935
s112830449
p00710
u668489394
1579139080
Python
Python3
py
Accepted
70
5616
455
def shuffle(arr, p, c): p -= 1 cut = arr[p: p + c] top = arr[:p] bot = arr[p + c:] return cut + top + bot if __name__ == '__main__': while True: N, R = list(map(int, input().split())) if N == 0 and R == 0: break arr = [ N - x for x in range(N) ] for...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,936
s242170370
p00710
u829695570
1578783617
Python
Python3
py
Accepted
60
5616
225
while 1: n,r = map(int,input().split()) if n==0: break a = [n-i for i in range(n)] for i in range(r): p,c = map(int,input().split()) a = a[p-1:p-1+c] + a[:p-1] + a[p-1+c:] print(a[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,937
s677378333
p00710
u803862921
1571657108
Python
Python3
py
Accepted
50
5616
282
while True: n, r = [int(x) for x in input().split()] if n == 0 and r == 0: break L = [ n-x for x in range(n)] for _ in range(r): p, c = [int(x) for x in input().split()] p -= 1 L = L[p:p+c] + L[:p] + L[p+c:] print(L[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,938
s347714668
p00710
u528682978
1569221424
Python
Python3
py
Accepted
50
5620
257
while True: n,r = map(int,input().split()) if n==0: break cards = [n-i for i in range(n)] for i in range(r): p,c=map(int,input().split()) p -= 1 cards = cards[p:p+c]+cards[:p]+cards[p+c:] print(cards[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,939
s661328298
p00710
u317942270
1562822338
Python
Python3
py
Accepted
50
5644
405
ans_list = [] while True: n,r = map(int,input().split()) if (n,r) == (0,0): break pc = [list(map(int,input().split())) for _ in range(r)] mt = list(range(1,n+1)[::-1]) def cal(p,c): global mt mt = mt[p-1:p-1+c] + mt[:p-1] + mt[p-1+c:] for p,c in pc: cal(p,c...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,940
s596559704
p00710
u023276896
1562715116
Python
Python3
py
Accepted
60
5624
432
# -*- coding: utf-8 -*- def main(): while 1: n, r = list(map(int,input().split())) l = list(range(n, 0, -1)) if n == 0 and r == 0: return 0 for _ in range(r): p, c = list(map(int, input().split())) l_ = l[p-1:p+c-1] l_.extend(l[:p-1]) ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,941
s357923062
p00710
u556131648
1562346025
Python
Python3
py
Accepted
50
5664
445
def solve(n, r, pc): deck = [n+1-i for i in range(1,n+1)] for p, c in pc: deck = deck[p-1:p+c-1] + deck[0:p-1] + deck[p+c-1:] return deck[0] def main(): ans = [] while True: n, r = map(int, input().split()) if (n==0) and (r==0): break pc = [list(map(int, ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,942
s682628474
p00710
u998734722
1562155800
Python
Python3
py
Accepted
50
5624
308
ans = [] while True: n,r = map(int,input().split()) if n == 0 and r == 0: break x = [i for i in range(1,n+1)] for i in range(r): p,c = map(int,input().split()) x = x[:n-(p-1+c)] + x[n-(p-1):] + x[n-(p-1+c):n-(p-1)] ans.append(x[-1]) print("\n".join(map(str,ans)))
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,943
s498399497
p00710
u657929974
1561866891
Python
Python3
py
Accepted
60
5616
295
while True: n,r = map(int,input().split()) if n == 0: break card = [] for i in range(n): card.append(n - i) for i in range(r): p,c = map(int,input().split()) card = card[p - 1:p + c - 1] + card[0:p - 1] + card[p + c - 1:n] print(card[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,944
s527292183
p00710
u464321546
1561799750
Python
Python3
py
Accepted
50
5616
309
def main(n, m): dp = [(i + 1) for i in range(n)] dp = dp[::-1] for _ in range(m): p, c = map(int, input().split()) dp = dp[p - 1:p + c - 1] + dp[:p - 1] + dp[p + c - 1:] print(dp[0]) while 1: n, r = map(int, input().split()) if n == r == 0: break main(n,r)
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,945
s593442242
p00710
u506598317
1561786251
Python
Python3
py
Accepted
50
5636
320
res = [] while True: n,k = map(int,input().split()) if n == 0 and k == 0: break card = [i for i in range(n,0,-1)] for i in range(k): p,c = map(int,input().split()) card = card[p-1:p-1+c]+card[:p-1]+card[p+c-1:] res.append(card[0]) for i in range(len(res)): print(res[i])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,946
s336762411
p00710
u264450287
1561509786
Python
Python3
py
Accepted
100
5620
413
while True: n,r=map(int,input().split()) if n==0 and r==0: break yama=[i for i in range(1,n+1)] for i in range(r): p,c=map(int,input().split()) yama1=[] for i in range(n-(p-1)-c,n-(p-1)): a=yama[i] yama1.append(a) #print(yama1) for i in range(len(yama1)): if yama1[i] in...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,947
s391472899
p00710
u215870135
1561194774
Python
Python3
py
Accepted
60
5616
273
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break cards = [n-i for i in range(n)] for i in range(r): p, c = map(int, input().split()) cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:] print(cards[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,948
s381091374
p00710
u853158149
1561127775
Python
Python3
py
Accepted
50
5612
242
while 1: n,r = map(int, input().split()) if n == r == 0: break a = list(range(1,n+1))[::-1] for i in range(r): p,c = map(int, input().split()) p -= 1 a = a[p:p+c]+a[:p]+a[p+c:] print(a[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,949
s764762990
p00710
u989573662
1561120610
Python
Python3
py
Accepted
70
5620
322
#!/usr/bin/env python3 while 1: n,r = map(int,input().split()) if n == 0 and r == 0: break card = [i+1 for i in range(n)] for i in range(r): p,c = map(int,input().split()) x = card[n-p-c+1:n-p+1] for j in x: card.remove(j) card += x print(card[-1]...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,950
s302868430
p00710
u595029599
1560694709
Python
Python3
py
Accepted
50
5608
275
while True: n, r = map(int, input().split()) if n == r == 0: break cs = list(range(n)) for i in range(r): p, c = map(int, input().split()) of = n - c - p + 1 cs = cs[:of] + cs[of + c:] + cs[of:of+c] print(cs[-1] + 1)
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,951
s473941873
p00710
u237184581
1560652297
Python
Python3
py
Accepted
60
5612
318
n, r = map(int, input().split()) while n != 0: hanafuda = list(range(1,n+1))[::-1] for _ in range(r): p, c = map(int, input().split()) hanafuda = hanafuda[p-1:p+c-1] + hanafuda[:p-1] + hanafuda[p+c-1:] print(hanafuda[0]) n, r = map(int, input().split())
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,952
s898305265
p00710
u037441960
1560512680
Python
Python3
py
Accepted
60
5612
346
while True : n, r = map(int, input().split()) if(n == 0 and r == 0) : break else : card = list() for i in range(n) : card.append(i + 1) card = card[::-1] for i in range(r) : p, c = map(int, input().split()) card = card[p-1:p+c-1] + card[:p-1] + card[p + c - 1:] # スライス ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,953
s946791384
p00710
u135085051
1560003858
Python
Python3
py
Accepted
60
5636
359
# Hanafuda Shuffle ans = [] while True: n, r = map(int, input().split()) if n == 0 and r == 0: break deck = [i + 1 for i in range(n)] deck.reverse() for i in range(r): p, c = map(int, input().split()) p -= 1 deck = deck[p:p+c] + deck[:p] + deck[p+c:] ans.append...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,954
s719511052
p00710
u777299405
1559903696
Python
Python3
py
Accepted
60
5608
281
while True: n, r = map(int, input().split()) if n == 0: break deck = list(range(n, 0, -1)) for i in range(r): p, c = map(int, input().split()) deck = deck[p - 1:p - 1 + c] + deck del deck[p - 1 + c:p - 1 + c + c] print(deck[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,955
s175406371
p00710
u197615397
1558019351
Python
Python3
py
Accepted
60
5620
256
while True: n, r = map(int, input().split()) if n == 0: break cards = list(range(n, 0, -1)) for p, c in (map(int, input().split()) for _ in [0]*r): cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:] print(cards[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,956
s977072836
p00710
u193874819
1557359244
Python
Python3
py
Accepted
60
5620
407
while True: n, r = map(int, input().split()) if (n,r) == (0,0): break else: cards = [i for i in range (1, n+1)] cards.reverse() for i in range (r): p,c = map(int,input().split()) top = cards[0 : p-1] mid = cards[p-1 : p+c-1] btm...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,957
s577814350
p00710
u701749469
1557314149
Python
Python3
py
Accepted
50
5616
427
def main(): while True: n, r = map(int, input().split()) if n == 0: break cards = [i for i in range (1, n+1)] cards.reverse() for i in range (r): p, c = map(int,input().split()) top = cards[0 : p-1] mid = cards[p-1 : p...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,958
s130770929
p00710
u763386533
1554359011
Python
Python3
py
Accepted
80
5624
267
n,r=map(int,input().split()) while n!=0 or r!=0: card=[i for i in range(n,0,-1)] for i in range(r): p,c=map(int,input().split()) for j in range(c): card.insert(0,card.pop(c+p-2)) print(card[0]) n,r=map(int,input().split())
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,959
s831803998
p00710
u289206800
1552030563
Python
Python3
py
Accepted
60
5612
331
while True: N, R = map(int, input().split()) if N == 0 and R == 0: break L = [i for i in range(N, 0, -1)] for i in range(R): p, c = map(int, input().split()) p -= 1 c = p + c tmp = L[p:c] tmp.extend(L[:p]) tmp.extend(L[c:]) L = tmp[:] p...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,960
s062598506
p00710
u717526540
1544762041
Python
Python3
py
Accepted
60
5612
275
while 1: n, r = map(int, input().split()) if n == 0: break card = list(range(n, 0, -1)) for _ in range(r): p, c = map(int, input().split()) tmp = card[p-1:p-1+c] del card[p-1:p-1+c] card[0:0] = tmp print(card[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,961
s954282463
p00710
u598814210
1543047311
Python
Python3
py
Accepted
70
5612
245
while True: n,r = map(int,input().split()) if(n==0): break cards = list(range(n,0,-1)) for i in range(r): p,c = map(int,input().split()) cards = cards[p-1:p+c-1] + cards[:p-1] + cards[p+c-1:] print(cards[0])
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,962
s966114767
p00710
u245823788
1530770386
Python
Python3
py
Accepted
60
5624
343
while True: n, r = map(int, input().split()) if n==0 and r==0: break yama = [i for i in range(n, 0, -1)] for _ in range(r): p, c = map(int, input().split()) up, bottom = [], [] up.extend(yama[p-1:p+c-1]) up.extend(yama[:p-1]) bottom.extend(yama[p+c-1:]) up.extend(bottom) yama = ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,963
s317067962
p00710
u281836941
1512991732
Python
Python3
py
Accepted
60
5628
556
# coding: utf-8 def q0(): while True: data=[] n=int(input()) if n==0: return for i in range(n): data.append(int(input())) print((sum(data)-max(data)-min(data))//(n-2)) def q1(): while True: n,r=map(int,input().split()) if n==0: ...
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,964
s520923100
p00710
u717727327
1418919228
Python
Python
py
Accepted
30
4224
300
while True: n, r = map(int, raw_input().split()) if n == 0 and r == 0: break x = range(1, n+1)[::-1] for _ in range(r): p, c = map(int, raw_input().split()) a = p-1 b = p+c-1 y = x[a:b] + x[:a] + x[b:] x = y[:] #print x print x[0]
p00710
<h1> <font color="#000">Problem A:</font> Hanafuda Shuffle </h1> <p> There are a number of ways to shuffle a deck of cards. Hanafuda shuffling for Japanese card game 'Hanafuda' is one such example. The following is how to perform Hanafuda shuffling. </p> <p> There is a deck of <I>n</I> cards. Starting from the <...
5 2 3 1 3 1 10 3 1 10 10 1 8 3 0 0
4 4
23,965
s536621748
p00711
u731235119
1421920107
Python
Python
py
Accepted
70
4336
772
def search(here, lb, ub, field): count = 0 if field[here[1]][here[0]] : count += 1 field[here[1]][here[0]] = 0 if lb[0] < here[0] : count += search((here[0]-1, here[1]), lb, ub, field) if lb[1] < here[1] : count += search((here[0], here[1]-1), lb, ub, field) if ub[0] > here[0] : count += search((h...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,966
s690758591
p00711
u120360464
1422863574
Python
Python
py
Accepted
70
4368
861
#! /usr/bin/env python # -*- coding: utf-8 -*- def rec(x, y, used, TILE): if not(0<=x<W) or not(0<=y<H): return elif used[y][x]==1 or TILE[y][x]=='#': return else: used[y][x] = 1 rec(x-1, y, used, TILE) rec(x+1, y, used, TILE) rec(x, y-1, used, TILE) ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,967
s359436729
p00711
u124909914
1426121579
Python
Python3
py
Accepted
90
6780
533
def search(x, y, m): if x < 0 or y < 0 \ or x >= len(m[0]) or y >= len(m): return 0 if m[y][x] == '#': return 0 m[y][x] = '#' return 1 + search(x+1,y, m) + search(x-1,y,m) \ + search(x,y+1,m) + search(x,y-1,m) while True: w, h = map(int, input().split()) ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,968
s461371649
p00711
u939118618
1429890594
Python
Python
py
Accepted
80
4500
626
delta = ((1, 0), (0, 1), (-1, 0), (0, -1)) def ds(here, lb, ub, field): if field[here[1]][here[0]] == "#": return 0 result = 1 field[here[1]][here[0]] = "#" for dx, dy in delta: next = (here[0]+dx,here[1]+dy) if lb[0] <= next[0] < ub[0] and lb[1] <= next[1] < ub[1]: result += ds(next, lb, ub, field) retur...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,969
s555939542
p00711
u408260374
1430129908
Python
Python
py
Accepted
90
4500
832
def dfs(x, y): for dx in [-1, 0, 1]: for dy in [-1, 0, 1]: if abs(dx) + abs(dy) == 2 or abs(dx) + abs(dy) == 2: continue next_x, next_y = x + dx, y + dy if 0 <= next_x < H and 0 <= next_y < W and isVisited[next_x][next_y] == 0 and tile[next_x][next_y] == '...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,970
s309738950
p00711
u939118618
1430131767
Python
Python
py
Accepted
80
4500
626
delta = ((1, 0), (0, 1), (-1, 0), (0, -1)) def ds(here, lb, ub, field): if field[here[1]][here[0]] == "#": return 0 result = 1 field[here[1]][here[0]] = "#" for dx, dy in delta: next = (here[0]+dx,here[1]+dy) if lb[0] <= next[0] < ub[0] and lb[1] <= next[1] < ub[1]: result += ds(next, lb, ub, field) retur...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,971
s829738546
p00711
u966364923
1436570210
Python
Python3
py
Accepted
90
6800
637
def dfs(tiles, w, h, x, y): cnt = 1 tiles[y][x] = '@' for dx,dy in ((0,1), (0,-1), (-1,0), (1,0)): if 0<=x+dx<w and 0<=y+dy<h and tiles[y+dy][x+dx]=='.': cnt += dfs(tiles, w, h, x+dx, y+dy) return cnt def main(): while True: W,H = [int(x) for x in input().split()] ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,972
s566688750
p00711
u489809100
1449144205
Python
Python
py
Accepted
40
6392
664
def check(x, y, count): array[x][y] = "$" count += 1 if array[x + 1][y] == "." : count = check(x + 1, y, count) if array[x - 1][y] == "." : count = check(x - 1, y, count) if array[x][y + 1] == "." : count = check(x, y + 1, count) if array[x][y - 1] == "." : count = check(x, y - 1, count) return count while True...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,973
s723428664
p00711
u488601719
1452499034
Python
Python
py
Accepted
100
6556
779
vx = [1, -1, 0, 0] vy = [0, 0, 1, -1] def isBound(n, m, x, y): return x < 0 or y < 0 or x >= n or y >= m def dfs(x, y): global field global cnt global v if isBound(W, H, x, y): return if field[y][x] == '#': return if v[y][x]: return else: v[y][x] = Tr...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,974
s931956674
p00711
u338932851
1455676636
Python
Python
py
Accepted
80
6740
751
import sys ct=1 def count(Map, w,h,i, j): global ct dx=[1,0,-1,0] dy=[0,1,0,-1] for k in range(4): ix=i+dy[k] jx=j+dx[k] if (0<=ix<h and 0<=jx<w and Map[ix][jx]=='.'): Map[ix][jx]='#' ct+=1 count(Map,w,h,ix,jx) while(True): input = map(in...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,975
s867307626
p00711
u667806071
1464097434
Python
Python
py
Accepted
90
6356
789
count = 0 role = {".": True, "@": False, "#": False} def now(xpoint, ypoint): return role[room[ypoint][xpoint]] def search(xpoint, ypoint): global count if 0 <= xpoint < wh[0] and 0 <= ypoint < wh[1] and now(xpoint, ypoint): count += 1 room[ypoint][xpoint] = "@" search(xpoint - 1, y...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,976
s494991570
p00711
u399892098
1487679232
Python
Python
py
Accepted
40
6504
778
def move_a(y,x,count): count += 1 li[x][y] = "#" if li[x-1][y] == ".": count = move_a(y,x-1,count) if li[x+1][y]== ".": count = move_a(y,x+1, count) if li[x][y-1]== ".": count = move_a(y-1,x, count) if li[x][y+1]== ".": count = move_a(y+1,x, count) return coun...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,977
s313084793
p00711
u131811591
1495022787
Python
Python3
py
Accepted
100
7840
870
# coding: utf-8 import sys def dfs(rw,cm): global flag flag[rw][cm] = 1 if 0 <= rw - 1 and mp[rw-1][cm] == '.' and flag[rw-1][cm] == 0: dfs(rw-1,cm) if cm + 1 < m and mp[rw][cm+1] == '.' and flag[rw][cm+1] == 0: dfs(rw,cm+1) if 0 <= cm - 1 and mp[rw][cm-1] == '.' and flag[rw][cm-1]...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,978
s117743483
p00711
u923668099
1495616169
Python
Python3
py
Accepted
90
7784
767
import sys cnt = 0 def solve(): while 1: w, h = map(int, sys.stdin.readline().split()) if w == h == 0: return room = [list(sys.stdin.readline().rstrip()) for i in range(h)] for i in range(h): if '@' in room[i]: si = i sj = ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,979
s760203850
p00711
u650459696
1497246860
Python
Python3
py
Accepted
80
7656
785
while True: w, h = map(int, input().split()) if w == 0: break a = [] for i in range(h): t = list(input()) a.append(t) if '@' in t: x = i y = t.index('@') stk = [[x, y]] c = 1 while True: if stk == []: break x...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,980
s499653928
p00711
u633333374
1512917276
Python
Python
py
Accepted
60
4696
840
while 1: w,h = map(int, raw_input().split()) if w == h == 0: break count = 0 cnt = 1 lst = [list(raw_input()) for i in range(h)] queue = [] for i in range(h): if "@" in lst[i]: wNow, hNow = lst[i].index("@"),i queue.append([hNow, wNow]) while 1: hNow,wNow = queue[0][0],queue[0][1] queue.pop(0) if ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,981
s544696410
p00711
u136916346
1530150788
Python
Python3
py
Accepted
90
5776
671
def fill(y,x): global l,c,w,h if 0<=x+1<w and 0<=y<h and l[y][x+1]==".": c+=1 l[y][x+1]=1 fill(y,x+1) if 0<=x-1<w and 0<=y<h and l[y][x-1]==".": c+=1 l[y][x-1]=1 fill(y,x-1) if 0<=x<w and 0<=y+1<h and l[y+1][x]==".": c+=1 l[y+1][x]=1 ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,982
s668445211
p00711
u500292616
1530684165
Python
Python
py
Accepted
70
4764
1,005
# -*- coding: utf-8 -*- #rea and blac h,w=1,1 count=0 def search(x,y): #マップの外側か壁の場合は何もしない #print(x,y) global count if x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#': return #以前に到達していたら何もしない if reached[y][x]: return reached[y][x]=1 count+=1 #pr...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,983
s780439300
p00711
u500292616
1530689370
Python
Python
py
Accepted
70
4764
1,005
# -*- coding: utf-8 -*- #rea and blac h,w=1,1 count=0 def search(x,y): #マップの外側か壁の場合は何もしない #print(x,y) global count if x<0 or x>w-1 or y<0 or y>h-1 or map_data[y][x]=='#': return #以前に到達していたら何もしない if reached[y][x]: return reached[y][x]=1 count+=1 #pr...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,984
s648827958
p00711
u779627195
1352890195
Python
Python
py
Accepted
60
18000
978
def walk(x, y): #print x,y global s global c global v if 0 <= x < w and 0 <= y < h: if v[y][x] is False: if s[y][x] == '@' or s[y][x] == '.': v[y][x] = True c += 1 ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,985
s651214780
p00711
u109084363
1359200087
Python
Python
py
Accepted
90
4668
926
import sys import collections x = [1, 0, -1, 0] y = [0, 1, 0, -1] while True: W, H = map(int, sys.stdin.readline().split()) if W == 0: break tile = [[0 for i in xrange(W + 2)] for j in xrange(H + 2)] visited = set() next = set() for i in xrange(H): line = raw_inpu...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,986
s234977191
p00711
u871745100
1370528076
Python
Python
py
Accepted
50
4376
464
mv=((0,1),(0,-1),(1,0),(-1,0)) def dfs(y,x): global cnt L[y][x]="" cnt+=1 for i,j in mv: mx=x+i my=y+j if 0<=mx<W and 0<=my<H and L[my][mx]==".": dfs(my,mx) while True: W,H=map(int,raw_input().split()) if W==H==0:break cnt=0 L=[list(raw_input()) for ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,987
s254344556
p00711
u260980560
1383937718
Python
Python
py
Accepted
80
4308
718
dx = [-1,0,1,0]; dy = [0,-1,0,1]; while 1: w,h = map(int, raw_input().split()) if w==h==0: break; m = []; s = []; sx = sy = 0; m.append('#'*(w+2)) for i in range(h): m.append("#"+raw_input()+"#") m.append('#'*(w+2)) f = [[0 for i in range(w+2)] for j in range(h+2)] for i in range...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,988
s007579925
p00711
u617183767
1396838679
Python
Python
py
Accepted
70
4336
1,204
# -*- coding: utf-8 -*- count = 0 def dfs(i, j, island): global count #print i, j dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)] if i < 0 or i >= len(island) or j < 0 or j >= len(island[0]): return if island[i][j] == '#' or island[i][j] == 'x': return island[i][j] = 'x' cou...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,989
s421153402
p00711
u633068244
1399450708
Python
Python
py
Accepted
50
4464
425
def solve(w,h): if 0 <= w < W and 0 <= h < H and tile[h][w] == ".": tile[h][w] = 0 solve(w+1,h); solve(w,h+1); solve(w-1,h); solve(w,h-1) while 1: W,H = map(int,raw_input().split()) if W == 0: break tile = [list(raw_input()) for i in range(H)] for h in range(H): try: sw = tile[h].index("@") sh = h t...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,990
s844572954
p00711
u823642749
1596840856
Python
Python3
py
Accepted
90
6016
989
""" 1. スタート地点の座標を取得 2. スタート地点からbfsをして到達可能な”.”の数を数える """ from collections import deque def bfs(h, w, f, s): count = 1 q = deque() q.append(s) move = ((0, 1), (0, -1), (1, 0), (-1, 0)) while q: i, j = q.popleft() for di, dj in move: ni , nj = i + di, j + dj ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,991
s723901660
p00711
u921537862
1592814870
Python
Python3
py
Accepted
100
6012
1,065
import sys sys.setrecursionlimit(10000000) MOD = 10 ** 9 + 7 INF = 10 ** 15 Dy = (-1,0,1,0) Dx = (0,1,0,-1) from collections import deque,defaultdict,Counter def solve(H,W): grid = [input() for _ in range(H)] cnt = [[0]*W for _ in range(H)] for i in range(H): for j in range(W): if grid[...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,992
s513215037
p00711
u299931928
1580212805
Python
Python3
py
Accepted
70
6040
1,471
# -*- coding: utf-8 -*- ''' 所要時間は、分位であった。 ''' # ライブラリのインポート #import re #正規表現 import sys input = sys.stdin.readline #import heapq #import bisect #import collections #import math #from pprint import pprint def main(): while 1: w, h = map(int, input().split()) if w == 0 and h == 0: break mp ...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,993
s320982113
p00711
u197615660
1579888988
Python
Python3
py
Accepted
90
6008
967
from collections import deque while True: w, h = map(int, input().split()) if w == 0 and h == 0: break else: m = [] d = deque() for i in range(h): r = input() m.append(list(r)) s = r.find('@') if s != -1: d.appe...
p00711
<H1><font color="#000">Problem B:</font> Red and Black</H1> <P> There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles...
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#. 11 9 .#......... .#.#######. .#.#.....#. .#.#.###.#. .#.#..@#.#. .#.#####.#. .#.......#. .#########. ........... 11 6 ..#..#..#.. ..#..#..#.. ..#..#..### ..#..#..#@. ..#..#..#.. ..#..#..#.. 7 7 ..#.#.. ..#.#.. ###.### ...@... ###.### ..#.#.. ..#.#.. 0 0...
45 59 6 13
23,994