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
s313818588
p00688
u797673668
1490618710
Python
Python3
py
Accepted
80
10300
506
import fractions while True: a, b, c = map(int, input().split()) if not a: break d = (b ** 2 - 4 * a * c) ** 0.5 if isinstance(d, complex) or d - int(d) > 1e-6: print('Impossible') continue num1, num2 = -b + int(d), -b - int(d) den = 2 * a cmn1, cmn2 = fractions.gcd(...
p00688
<h1> Factorization of Quadratic Formula</h1> <p>As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of advanced algebra...
2 5 2 1 1 1 10 -7 0 1 0 -3 0 0 0
2 1 1 2 Impossible 10 -7 1 0 Impossible
23,792
s627880462
p00688
u647766105
1380087765
Python
Python
py
Accepted
40
5988
583
from fractions import gcd def func(a, b): if a < 0: return (-a, -b) return a, b while True: a, b, c = map(int, raw_input().split()) if (a, b, c) == (0, 0, 0): break try: d = (b**2 - 4*a*c)**0.5 if not int(d) == d: raise e,f = map(int,(-b+d, -b-d)) ...
p00688
<h1> Factorization of Quadratic Formula</h1> <p>As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of advanced algebra...
2 5 2 1 1 1 10 -7 0 1 0 -3 0 0 0
2 1 1 2 Impossible 10 -7 1 0 Impossible
23,793
s132352594
p00688
u943441430
1546997865
Python
Python3
py
Accepted
50
5692
1,011
# AOJ 1106 import sys import math def gcd(a, b): if a < b: a, b = b, a r = b while r != 0: r = a % b if r == 0: return b a, b = b, r def factor(a, b, c): disc = b * b - 4 * a * c if disc < 0: print("Impossible") return rd = math.sqrt...
p00688
<h1> Factorization of Quadratic Formula</h1> <p>As the first step in algebra, students learn quadratic formulas and their factorization. Often, the factorization is a severe burden for them. A large number of students cannot master the factorization; such students cannot be aware of the elegance of advanced algebra...
2 5 2 1 1 1 10 -7 0 1 0 -3 0 0 0
2 1 1 2 Impossible 10 -7 1 0 Impossible
23,794
s122428859
p00690
u647766105
1379410903
Python
Python
py
Accepted
30
4296
1,016
def make_routes(ns,used, cur): if all(used[cur]): yield [] else: for i in (d for d,s in zip(range(ns+1), used[cur]) if not s): used[cur][i] = used[i][cur] = True for ret in make_routes(ns,used,i): yield [[cur, i]] + ret used[cur][i] = used[i][c...
p00690
<h1> A Long Ride on a Railway</h1> <p> Travelling by train is fun and exciting. But more than that indeed. Young challenging boys often tried to purchase the longest single tickets and to single ride the longest routes of various railway systems. Route planning was like solving puzzles. However, once assisted by co...
6 5 1 3 10 2 3 12 3 4 2 4 5 13 4 6 11 10 10 1 2 11 2 3 25 2 5 81 2 6 82 4 5 58 5 9 68 6 7 80 6 9 67 8 9 44 9 10 21 0 0
27 2 3 4 5 378 6 2 5 9 6 7
23,795
s025948998
p00691
u847467233
1531538435
Python
Python3
py
Accepted
60
5640
328
# AOJ 1109: Fermat's Last Theorem # Python3 2018.7.14 bal4u from bisect import bisect_left tbl = [i**3 for i in range(1111)] while True: z = int(input()) if z == 0: break ma = 0 for x in range(z-1, 0, -1): y = bisect_left(tbl, tbl[z]-tbl[x])-1 if tbl[y] > tbl[x]: break ma = max(ma, tbl[x]+tbl[y]) print(tbl...
p00691
<H1> Fermat's Last Theorem </H1> <p> In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture. </p> <p> If Fe...
6 4 2 0
27 10 6
23,796
s922213640
p00691
u858885710
1411733165
Python
Python
py
Accepted
60
4372
365
def my_input(): inp = int(raw_input()) result = [] while inp != 0: result.append(inp) inp = int(raw_input()) return result def calc1(v): return min([calc2(v ** 3 - x ** 3) for x in range(1,v)]) def calc2(v): return v - int(v ** (1.0/3)) ** 3 def main(): for x in [calc1(i) ...
p00691
<H1> Fermat's Last Theorem </H1> <p> In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture. </p> <p> If Fe...
6 4 2 0
27 10 6
23,797
s299412777
p00691
u266872031
1434284882
Python
Python
py
Accepted
80
4440
214
import math while(1): z=int(raw_input()) if z==0: break else: k=0 for x in range(1,z): y=int(pow(z**3-x**3,1/3.)) k=max(k,x**3+y**3) print z**3-k
p00691
<H1> Fermat's Last Theorem </H1> <p> In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture. </p> <p> If Fe...
6 4 2 0
27 10 6
23,798
s097545235
p00691
u633068244
1396536471
Python
Python
py
Accepted
50
4292
155
while 1: n3=mn=input()**3 if n3==0:break i=0 while 1: i+=1 i3=i**3 j=int((n3-i3)**(1/3.0)) if j<i:break m=n3-i3-j**3 if m<mn:mn=m print mn
p00691
<H1> Fermat's Last Theorem </H1> <p> In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture. </p> <p> If Fe...
6 4 2 0
27 10 6
23,799
s966681522
p00691
u633068244
1396536597
Python
Python
py
Accepted
50
4292
159
while 1: n3=mn=input()**3 if n3==0:break i=0 while 1: i+=1 i3=i**3 j3=int((n3-i3)**(1/3.0))**3 if j3<i3:break m=n3-i3-j3 if m<mn:mn=m print mn
p00691
<H1> Fermat's Last Theorem </H1> <p> In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture. </p> <p> If Fe...
6 4 2 0
27 10 6
23,800
s561099353
p00691
u633068244
1396536881
Python
Python
py
Accepted
50
4288
150
while 1: z3=m=input()**3 if z3==0:break x=0 while 1: x+=1 x3=x**3 y=int((z3-x3)**(1/3.)) if y<x:break n=z3-x3-y**3 if n<m:m=n print m
p00691
<H1> Fermat's Last Theorem </H1> <p> In the 17th century, Fermat wrote that he proved for any integer $n \geq 3$, there exist no positive integers $x$, $y$, $z$ such that $x^n + y^n = z^n$. However he never disclosed the proof. Later, this claim was named Fermat's Last Theorem or Fermat's Conjecture. </p> <p> If Fe...
6 4 2 0
27 10 6
23,801
s428302328
p00692
u847467233
1531548912
Python
Python3
py
Accepted
50
5612
870
# AOJ 1110: Patience # Python3 2018.7.8 bal4u pair = [[1,4,5], [2,4,5,6], [3,5,6,7], [6,7], [5,8,9], [6,8,9,10], [7,9,10,11], [10,11], [9,12,13], [10,12,13,14], [11,13,14,15], [14,15], [13,16,17], [14,16,17,18], [15,17,18,19], [18,19], [17], [18], [19]] def combi(cd, n): global ans ans = min(ans, n) if n == 0: ...
p00692
<H1> Patience </H1> <p> As the proverb says, </p> <BLOCKQUOTE> <I>"Patience is bitter, but its fruit is sweet."</I> </BLOCKQUOTE> <p> Writing programs within the limited time may impose some patience on you, but you enjoy it and win the contest, we hope. </P> <p> The word "patience" has the meaning of perseverance,...
4 1 4 5 2 3 1 4 3 5 4 2 2 4 5 2 3 1 1 3 5 5 1 5 1 4 5 3 2 3 2 1 4 1 4 5 3 2 3 4 2 1 2 1 2 5 4 5 4 2 1 2 1 3 5 3 4 3 3 5 4 4 2 3 1 2 5 3 1 3 5 4 2 1 5 4 1 4 5 3 2
0 4 12 0
23,802
s929245239
p00695
u847467233
1531551631
Python
Python3
py
Accepted
60
5612
557
# AOJ 1114: Get a Rectangular Field # Python3 2018.7.8 bal4u s = [[0 for c in range(6)] for r in range(6)] for k in range(int(input())): if k > 0: input() for r in range(5): a = list(map(int, input().split())) for c in range(5): s[r+1][c+1] = s[r+1][c]+a[c] ans = 0; for r in range(1, 6): for c in range(1, 6)...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,803
s612171685
p00695
u085454708
1422235423
Python
Python
py
Accepted
80
4404
2,094
max_size = 0 def get_max_rectangle(field): for i in range(len(field)): for j in range(len(field[0])): if field[i][j] == 1: max_rectangle_right(field, {'x0':j, 'y0':i, 'x1':j, 'y1':i}) def check_expandable(field, rect, a0, a1, b, c): return rect[a1] - rect[a0] + 1 == len([i ...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,804
s788761819
p00695
u104911888
1372248150
Python
Python
py
Accepted
30
4388
1,545
t=input() for p in range(t): H=W=5 L=[["0"]+raw_input().split()+["0"] for i in range(H)] L.append(["0"]*(W+2)) L.insert(0,["0"]*(W+2)) dp=[[set() for i in range(W+2)] for i in range(H+2)] T=[[[0,0] for i in range(W+2)] for i in range(H+2)] for i in range(1,H+1): for j in range(1,W+1)...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,805
s183279500
p00695
u300645821
1392388983
Python
Python
py
Accepted
30
4284
924
#!/usr/bin/python #http://www.checkio.org/mission/spaceship-landing-strip/ verifier. #sadly TLE for aizu0116 import sys if sys.version_info[0]>=3: raw_input=input def checkio(data): y=len(data) x=len(data[0]) m=[[0]*x for i in range(y)] for j in range(y): r=0 for i in range(x): #if data[j][i]=='.': r+=1 ...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,806
s388193479
p00695
u633068244
1399557284
Python
Python
py
Accepted
20
4292
534
W = H = 5 m = input() for r in range(m): M = [map(int,raw_input().split()) for i in range(H)] A = [[0]*W for i in range(H)] B = [[0]*W for i in range(H)] ans = 1 for h in range(H): L = 0 for w in range(W): if M[h][w] == 1: L += 1 else: L = 0 A[h][w] = L B[h][w] = (B[h-1][w] if h > 0 else 0)...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,807
s983980720
p00695
u300645821
1400581047
Python
Python
py
Accepted
30
4272
600
import sys if sys.version_info[0]>=3: raw_input=input def checkio(data): y=len(data) x=len(data[0]) m=[[0]*x for i in range(y)] for j in range(y): r=0 for i in range(x): #if data[j][i]=='.': r+=1 if data[j][i]==1: r+=1 else: r=0 m[j][i]=r r=0 for i in range(x): for j in range(y): M=9999999 ...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,808
s646193500
p00695
u300645821
1400581057
Python
Python3
py
Accepted
50
6740
600
import sys if sys.version_info[0]>=3: raw_input=input def checkio(data): y=len(data) x=len(data[0]) m=[[0]*x for i in range(y)] for j in range(y): r=0 for i in range(x): #if data[j][i]=='.': r+=1 if data[j][i]==1: r+=1 else: r=0 m[j][i]=r r=0 for i in range(x): for j in range(y): M=9999999 ...
p00695
<H1> Get a Rectangular Field </H1> <P> Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular...
3 1 1 0 1 0 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0 0 1
4 3 8
23,809
s742972128
p00700
u847467233
1531552253
Python
Python3
py
Accepted
40
5604
316
# AOJ 1119: Exploring Caves # Python3 2018.7.14 bal4u for _ in range(int(input())): ans = x = y = tx = ty = 0 while True: dx, dy = map(int, input().split()) if (dx | dy) == 0: break x += dx; y += dy d = x*x+y*y if d > ans: ans, tx, ty = d, x, y elif d == ans and tx < x: tx, ty = x, y print(tx, ty)
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,813
s557441630
p00700
u488601719
1452340489
Python
Python
py
Accepted
50
6344
395
n = input() for i in range(n): maxL = 0 cx = 0 cy = 0 maxx = 0 maxy = 0 while True: dx, dy = map(int, raw_input().split()) if dx == 0 and dy == 0: break cx += dx cy += dy d = cx ** 2 + cy ** 2 if maxL < d or (d == maxL and cx > maxx):...
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,814
s001179145
p00700
u078042885
1484241900
Python
Python3
py
Accepted
40
7540
236
for _ in range(int(input())): m=dx=dy=0 while 1: x,y=map(int,input().split()) if x==y==0:break dx+=x dy+=y l=dx*dx+dy*dy if (m==l and mx<dx) or m<l:m,mx,my=l,dx,dy print(mx,my)
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,815
s669393576
p00700
u399892098
1491970007
Python
Python
py
Accepted
20
6260
644
# coding: utf-8 numt = input() for i in xrange(numt): count = 0 lis = [[0,0]] ma = 0 tmpl = [0,0] while True: x,y = map(int,raw_input().split()) tempx = lis[count][0] + x tempy = lis[count][1] + y count += 1 if(x == 0 and y == 0): for l in lis: ...
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,816
s778590960
p00700
u399892098
1491970029
Python
Python
py
Accepted
20
6348
663
# coding: utf-8 # Here your code ! numt = input() for i in xrange(numt): count = 0 lis = [[0,0]] ma = 0 tmpl = [0,0] while True: x,y = map(int,raw_input().split()) tempx = lis[count][0] + x tempy = lis[count][1] + y count += 1 if(x == 0 and y == 0): ...
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,817
s156120116
p00700
u434428594
1349623279
Python
Python
py
Accepted
40
7564
882
from pprint import pprint T = int(raw_input()) for T_ in xrange(T): log = [] curX = 0 curY = 0 log.append((0, 0)) rx, ry = log[0] while True: dx, dy = map(int, raw_input().split()) if dx == 0 and dy == 0: break elif dx == 0: if dy > 0: for y_ in xrange(dy): curY...
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,818
s622181892
p00700
u779627195
1352736192
Python
Python
py
Accepted
20
4324
496
def dist(pos): r = [] for i in xrange(len(cave)): r.append(((cave[i][0]**2 + cave[i][1]**2), cave[i])) r.sort(reverse = True) return r[0][1] n = int(raw_input()) for i in xrange(n): pos = [0,0] cave = [] while 1: x,y = map(int, raw_input().split()) if x == 0 and y ==...
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,819
s845439981
p00700
u104911888
1371909940
Python
Python
py
Accepted
10
4228
308
for i in range(input()): cx=cy=0 maxValue=mx=my=0 while True: dx,dy=map(int,raw_input().split()) if dx==dy==0:break cx+=dx cy+=dy d=cx*cx+cy*cy if d>maxValue or (d==maxValue and cx>mx): maxValue=d mx,my=cx,cy print mx,my
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,820
s770608087
p00700
u633068244
1399992427
Python
Python
py
Accepted
20
4224
289
n = input() ax = ay = x = y = mx = 0 while n > 0: dx,dy = map(int,raw_input().split()) if dx == dy == 0: print ax,ay n -= 1 ax = ay = x = y = mx = 0 continue x += dx; y += dy if x*x + y*y > mx: mx = x**2 + y**2 ax,ay = x,y elif x*x + y*y == mx: if x > ax: ax,ay = x,y
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,821
s412052167
p00700
u668489394
1579160126
Python
Python3
py
Accepted
40
5612
659
if __name__ == '__main__': TC = int(input()) for _ in range(TC): maxDist = 0 treasureX = 0 treasureY = 0 posX = 0 posY = 0 while True: x, y = [ int(x) for x in list(filter(lambda x: x != '', \ input().strip().split(' '))) ] ...
p00700
<h1> Exploring Caves </h1> <p>There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robo...
3 1 0 0 1 -1 0 1 0 0 5 -1 0 0 -1 5 0 0 1 0 -1 1 0 0 -4 -3 0 0 3 2 0 0 -2 -1 0 0 1 0 -1 1 0 0 2 -2 0 0 -3 3 0 0 4 -4 0 0 -5 -2 0 0 0 1 0 -1 0 0 0 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0
6 5 1 0 2 1
23,822
s410645883
p00701
u266872031
1530285190
Python
Python3
py
Accepted
50
5632
1,606
while(1): m=int(input()) if m==0: break #root, before, next, top, rank A=[[i for i in range(m+1)],[0 for i in range(m+1)],[0 for i in range(m+1)],[i for i in range(m+1)],[1 for i in range(m+1)]] while(1): I,J=map(int, input().split()) if I==0: break if I==J: ...
p00701
<h1> Pile Up! </h1> <p>There are cubes of the same size and a simple robot named Masato. Initially, all cubes are on the floor. Masato can be instructed to pick up a cube and put it on another cube, to make piles of cubes. Each instruction is of the form `pick up cube <i>A</i> and put it on cube <i>B</i> (or on th...
3 1 3 2 0 0 0 4 4 1 3 1 1 2 0 0 5 2 1 3 1 4 1 3 2 1 1 0 0 0
1 2 end 1 1 2 end 1 4 end
23,823
s051425089
p00702
u659302741
1478951842
Python
Python3
py
Accepted
60
7840
1,221
def count_characters(word, dic, kcs, kcs2, kcs2_1): prev1 = None i = 0 l = len(word) while i < l: c = word[i] if c in kcs2_1 and i < l - 1: c2 = word[i + 1] if (c + c2) in kcs2: if prev1 != None: dic[prev1][c + c2] += 1 ...
p00702
<h1> Kanglish : Analysis on Artificial Language </h1> <p>The late Prof. Kanazawa made an artificial language named Kanglish, which is similar to English, for studying mythology. Words and sentences of Kanglish are written with its own special characters called "Kan-characters". The size of the set of the Kan-char...
3 nai tiruvantel ar varyuvantel i valar tielyama nu vilya qua ist qda quang ncw psts svampti tsuldya jay quadal ciszeriol
a r 3 b a 0 c i 1 d a 2 e l 3 f a 0 g a 0 h a 0 i s 2 j a 1 k a 0 l y 2 m a 1 n a 1 o l 1 p a 0 q d 1 r i 1 s t 1 t i 3 u v 2 v a 5 w a 0 x a 0 y a 3 z e 1 ld y 1 mb a 0 mp t 1 nc w 1 nd a 0 ng a 0 nt e 2 nw a 0 ps ts 1 qu a 3 cw a 0 ts u 1
23,824
s810368775
p00705
u046108504
1555867985
Python
Python3
py
Accepted
90
6036
630
import collections while True: N, Q = map(int, input().split()) if N == 0 and Q == 0: break D = [] for _ in range(N): i = list(map(int, input().split())) del i[0] [D.append(ii) for ii in i] if not len(D) == 0: c = collections.Counter(D) cc = c.most_co...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,825
s889041324
p00705
u617183767
1420255345
Python
Python
py
Accepted
80
4680
1,042
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' while True: n, q = map(...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,826
s374016451
p00705
u316268279
1420617345
Python
Python3
py
Accepted
100
6724
514
#!/usr/bin/env python # -*- coding: utf-8 -*- while True: N,Q = map(int,input().split(" ")) if N == 0 and Q == 0: break dateList = [0 for i in range(101)] for i in range(N): date = list(map(int,input().split())) for d in date[1:]: dateList[d] += 1 max_participant...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,827
s005741187
p00705
u731235119
1421861760
Python
Python
py
Accepted
60
4220
324
while 1: n, q = map(int, raw_input().split(" ")) if (n, q) == (0,0): break date_total = [0 for i in range(100)] for i in range(n): date = map(int, raw_input().split(" ")) for j in range(1,date[0]+1): date_total[date[j]] += 1 best = max(date_total) if best < q: print 0 else : print date_total.index(b...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,828
s302218844
p00705
u120360464
1422054822
Python
Python
py
Accepted
60
4224
366
#! /usr/bin/env python # -*- coding: utf-8 -*- (N, Q) = map(int, raw_input().split()) while N!=0 and Q!=0: H=[0]*101 for i in range(N): q = map(int, raw_input().split()) for j in range(1, len(q)): H[q[j]] += 1 if Q <= max(H): print H.index(max(H)) else: print...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,829
s420703067
p00705
u647766105
1428079016
Python
Python
py
Accepted
60
4204
257
while True: N, Q = map(int, raw_input().split()) if (N, Q) == (0, 0): break count = [Q-1] + [0] * 100 for _ in xrange(N): for d in map(int, raw_input().split())[1:]: count[d] += 1 print count.index(max(count))
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,830
s701993575
p00705
u998188826
1443287488
Python
Python3
py
Accepted
100
7940
303
from collections import Counter while True: n, q = map(int, input().split()) if (n, q) == (0, 0): break r = [] for i in range(n): d = list(map(int, input().split())) if len(d) > 1: r += d[1:] r = Counter(r).most_common() if len(r) > 0 and r[0][1] >= q: print(r[0][0]) else: print(0)
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,831
s057892537
p00705
u488601719
1452405385
Python
Python
py
Accepted
80
6280
440
while True: n, q = map(int, raw_input().split()) if n == 0: break m = {} for _ in range(n): d = map(int, raw_input().split()) for i in range(1, len(d)): if d[i] in m: m[d[i]] += 1 else: m[d[i]] = 1 maxk = 0 maxv ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,832
s375130918
p00705
u685815919
1475045043
Python
Python
py
Accepted
70
6380
397
while True: N,Q = map(int, raw_input().split()) if N==Q==0: break schedule = [0] * 101 for _ in xrange(N): ipt = map(int, raw_input().split()) for i in xrange(1, ipt[0]+1): schedule[ipt[i]] += 1 bestday = 0 bestnum = 0 for i in xrange(1, 101): if bestnum < schedule[i]: bestday = i ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,833
s828008038
p00705
u260980560
1483860871
Python
Python
py
Accepted
70
6352
297
while 1: n, q = map(int, raw_input().split()) if n==0: break d = [0]*101 for i in xrange(n): D = map(int, raw_input().split()) for j in xrange(D[0]): d[D[j+1]] += 1 v = max(d) if v < q: print 0 else: print d.index(v)
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,834
s231827651
p00705
u146816547
1524749351
Python
Python
py
Accepted
70
4676
365
while True: N, Q = map(int, raw_input().split()) if N == 0 and Q == 0: break t = [map(int, raw_input().split())[1:] for _ in range(N)] table = [[i, 0] for i in range(101)] for i in t: for j in i: table[j][1] += 1 table.sort(reverse=True, key=lambda x: x[1]) p...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,835
s486365887
p00705
u779627195
1352738552
Python
Python
py
Accepted
60
4236
470
while 1: n,q = map(int, raw_input().split()) if n == 0 and q == 0: break dates = [0 for i in xrange(100)] for i in xrange(n): cDate = map(int, raw_input().split()) if cDate[0] != 0: for j in xrange(cDate[0]): dates[cDate[j+1]] += 1 nom = max(dates) if ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,836
s804832590
p00705
u109084363
1359199088
Python
Python
py
Accepted
80
4624
674
import sys import collections while True: N, Q = map(int, sys.stdin.readline().split()) if N == 0: break counter = collections.Counter() for i in xrange(N): date = map(int, sys.stdin.readline().split()) if date[0] != 0: counter.update(date[1:]) if len(counte...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,837
s337475479
p00705
u759949288
1361816674
Python
Python
py
Accepted
70
4228
291
while True: n, q = map(int, raw_input().split()) if n == q == 0: break counts = [0] * 101 maxd = 0 for i in xrange(n): data = map(int, raw_input().split()[1:]) for d in data: counts[d] += 1 maxd = max(maxd, counts[d]) if q <= maxd: print counts.index(maxd) else: print 0
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,838
s746455084
p00705
u104911888
1369792595
Python
Python
py
Accepted
50
4228
237
while True: N,Q=map(int,raw_input().split()) if N==Q==0:break T=[0]*101 for i in range(N): L=map(int,raw_input().split()) for j in L[1:]: T[j]+=1 m=max(T) print 0 if m<Q else T.index(m)
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,839
s803529925
p00705
u621997536
1387291972
Python
Python
py
Accepted
50
4224
350
while 1: day = [0] * 100 n, q = map(int, raw_input().split()) if not n: break for i in range(n): data = map(int, raw_input().split()) for j in range(1, len(data)): day[data[j] - 1] += 1 m = max(day) if m >= q: for i in range(0, len(day)): if day[i] == m: print i + 1 ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,840
s062631270
p00705
u633068244
1399992936
Python
Python
py
Accepted
60
4208
206
while 1: N,Q = map(int,raw_input().split()) if N == 0: break C = [0]*100 for _ in range(N): D = map(int,raw_input().split()) for i in D[1:]: C[i] += 1 print C.index(max(C)) if max(C) >= Q else 0
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,841
s622778774
p00705
u057189799
1597363496
Python
Python3
py
Accepted
100
5616
490
while True: N, Q = map(int, input().split()) if N == 0 and Q == 0: break counts = [0 for i in range(100)] for i in range(N): tmp = list(map(int, input().split())) M = tmp[0] for i in range(M): counts[tmp[i + 1] - 1] += 1 max_count = max(counts...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,842
s176471683
p00705
u206124123
1584252940
Python
Python3
py
Accepted
90
5624
1,118
def get_input(): data_list = input().split() for i in range(len(data_list)): data_list[i] = int(data_list[i]) return data_list def make_dict(day_dict, data_list): candidate_num =data_list[0] + 1 for i in range(1, candidate_num): data = data_list[i] if data in day_dict: ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,843
s762595818
p00705
u245823788
1562575206
Python
Python3
py
Accepted
90
6008
371
from collections import defaultdict while True: n, q = list(map(int, input().split())) if n==0: break t = defaultdict(int) for i in range(n): d = list(map(int, input().split())) for j in range(1, len(d)): t[d[j]]+=1 tt = sorted(t.items()) tt.sort(key=lambda x: -x[1]) if len(tt)==0 or tt...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,844
s036835299
p00705
u464321546
1561806665
Python
Python3
py
Accepted
60
6004
558
from collections import defaultdict def main(n, m): d = defaultdict(int) for _ in range(n): M = list(map(int, input().split())) for num, i in enumerate(M): if num == 0: continue d[i] += 1 ans = 10**20 for key, value in d.items(): if value > m: ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,845
s791466417
p00705
u215870135
1561254859
Python
Python3
py
Accepted
100
5616
433
while True: n, q = map(int, input().split()) if n == 0: break count = [0] * 101 for i in range(n): dates = list(map(int, input().split())) for d in range(1, len(dates)): count[dates[d]] += 1 ind = 0 max_ = 0 for i in range(101): if max_ < count[i]:...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,846
s432621400
p00705
u788553535
1560493559
Python
Python3
py
Accepted
90
5636
418
while True: N,Q = map(int,input().split()) if N+Q==0: break date = [0 for i in range(1000)] for i in range(N): M = list(map(int,input().split())) for i in M[1:]: date[i]+=1 a = max(date) if a>=N: for i in range(1000): if N==date[i]: print(i) break elif N>a>=Q: ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,847
s779092820
p00705
u489876484
1560416756
Python
Python3
py
Accepted
80
5632
417
def main(): while True: n,q = map(int,input().split()) if not n and not q: return res = [0 for _ in range(1000)] for _ in range(n): for m in list(map(int,input().split()))[1::]: res[m] += 1 ans = max(res) if ans < q: ...
p00705
<H1> When Can We Meet? </H1> <P> The ICPC committee would like to have its meeting as soon as possible to address every little issue of the next contest. However, members of the committee are so busy maniacally developing (possibly useless) programs that it is very difficult to arrange their schedules for the meet...
3 2 2 1 4 0 3 3 4 8 3 2 4 1 5 8 9 3 2 5 9 5 2 4 5 7 9 3 3 2 1 4 3 2 5 9 2 2 4 3 3 2 1 2 3 1 2 9 2 2 4 0 0
4 5 0 2
23,848
s494227261
p00706
u731235119
1421907157
Python
Python
py
Accepted
90
4396
793
while 1: n = int(raw_input()) if n == 0: break w,h = map(int,raw_input().split(" ")) tree_loc = [map(int,raw_input().split(" ")) for i in range(n)] s,t = map(int,raw_input().split(" ")) get_field = [[0 for i in range(0,w-s+2)] for j in range(0,h-t+2)] for x,y in tree_loc: get_field[max(y-t+1,1)][max(x-s+1,1...
p00706
<H1> Get Many Persimmon Trees </H1> <P> Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of Aizu, had decided to grant him a recta...
16 10 8 2 2 2 5 2 7 3 3 3 8 4 2 4 5 4 8 6 4 6 7 7 5 7 8 8 1 8 4 9 6 10 3 4 3 8 6 4 1 2 2 1 2 4 3 4 4 2 5 3 6 1 6 2 3 2 0
4 3
23,849
s933760355
p00707
u017525488
1439557249
Python
Python
py
Accepted
100
4272
598
# -*- coding: utf-8 -*- import sys while True: w, h = map(int, sys.stdin.readline().split( " " ) ) if w == 0 and h == 0: break table = [] for i in range(h): table.append( sys.stdin.readline() ) dp = [[0 for i in range(w + 1)] for j in range(h + 1)] for i in range( h ): ...
p00707
<H1>The Secret Number</H1> <P> Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1. </P> <CENTER> <DIV style="margin-bottom: 5mm"><img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_sec...
7 4 9R2A993 0E314A0 8A900DE 820R037 6 7 JH03HE ID7722 0DA1AH 30C9G5 99971A CA7EAI AHLBEM 20 2 A1234567891234CBDEGH BDEDF908034265091499 0 0
23900037 771971 12345908034265091499
23,850
s970564236
p00709
u072053884
1551005654
Python
Python3
py
Accepted
80
5696
2,936
def solve(): from itertools import combinations from sys import stdin file_input = stdin while True: W, H = map(int, file_input.readline().split()) if W == 0: break carpets = [] state = 0 # Largest Square algorithm prev =...
p00709
<H1>Square Carpets</H1> <P> Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy. </P> <P> But, to his disappointment, the floor of its living room has some sc...
4 3 0 1 1 1 1 1 1 1 1 1 1 1 8 5 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 8 8 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 0 10 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 1 1 0 1 1 1 1 1 1 ...
2 6 14 29
23,851
s240668063
p00710
u576786938
1534821432
Python
Python3
py
Accepted
50
5616
261
while True: n,r = map(int,input().split()) if n==0 and r==0: break cut = [i for i in range(1,n+1)][::-1] for i in range(r): p,c = map(int,input().split()) cut = cut[p-1:p+c-1] + cut[:p-1] + cut[p+c-1:] print(cut[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,852
s722339853
p00710
u576786938
1534821448
Python
Python3
py
Accepted
50
5616
261
while True: n,r = map(int,input().split()) if n==0 and r==0: break cut = [i for i in range(1,n+1)][::-1] for i in range(r): p,c = map(int,input().split()) cut = cut[p-1:p+c-1] + cut[:p-1] + cut[p+c-1:] print(cut[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,853
s280873655
p00710
u328199937
1555773519
Python
Python3
py
Accepted
70
5624
305
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break card = [i for i in range(n, 0, -1)] for i in range(r): p, c = map(int, input().split()) p -= 1 card = card[p:p + c] + card[:p] + card[p + c:] #print(card) 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,854
s041736827
p00710
u046108504
1555781456
Python
Python3
py
Accepted
60
5620
505
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break deck = [i + 1 for i in range(n)] for shuffle in range(r): p, c = map(int, input().split()) # print("start: {}, end: {}".format(len(deck) - p - c + 1, len(deck) - p + 1)) hoge = deck[len(deck) - 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,855
s764378478
p00710
u788553535
1559130304
Python
Python3
py
Accepted
60
5620
272
while True: n,r = map(int,input().split()) if n*r==0: break yama = [i+1 for i in range(n)] for i in range(r): p,c = map(int,input().split()) s_p = yama[n-(p-1):n] s_c = yama[n-(p-1)-c:n-(p-1)] yama = yama[:n-(p-1)-c]+s_p+s_c print(yama[n-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,856
s740970865
p00710
u191474223
1559135287
Python
Python3
py
Accepted
70
7512
625
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.st...
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,857
s973774934
p00710
u200148444
1559555919
Python
Python3
py
Accepted
60
5616
214
while True: n,r=map(int,input().split()) if n==0:exit() l=[n-i for i in range(n)] for j in range (r): p,c=map(int,input().split()) l=l[p-1:p+c-1]+l[:p-1]+l[p+c-1:] 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,858
s706243176
p00710
u966364923
1419218839
Python
Python3
py
Accepted
60
6724
288
while True: (n, r) = [int(x) for x in input().split()] if n==0 and r==0: exit() cards = [n-i for i in range(n)] for _ in range(r): (p, c) = [int(x) for x in 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,859
s525929189
p00710
u120360464
1421735537
Python
Python
py
Accepted
30
4220
351
#! /usr/bin/env python # -*- coding: utf-8 -*- (n, r) = map(int, raw_input().split()) while n!=0 and r!=0: list = [n-j for j in range(n)] for i in range(r): (p, c) = map(int, raw_input().split()) p -= 1 list = list[p:p+c] + list del list[p+c:p+c+c] print list[0] (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,860
s114454573
p00710
u731235119
1421824342
Python
Python
py
Accepted
30
4220
270
n,r = map (int, raw_input().split(" ")) while (n,r) != (0,0) : deck = [n - i for i in range(n)] for i in range(r): p,c = map (int, raw_input().split(" ")) deck = deck[p-1:p-1+c] + deck[:p-1] + deck[p-1+c:] print deck[0] n,r = map (int, raw_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,861
s104649114
p00710
u124909914
1424764340
Python
Python3
py
Accepted
60
6720
377
#! /usr/bin/python3 while True: n, r = list(map(int, input().split())) if n == 0 and r == 0 : break deck = list(range(n, 0, -1)) for i in range(r): p, c = list(map(int, input().split())) p -= 1 p_cards = deck[:p] c_cards = deck[p:p+c] remain = deck[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,862
s915793822
p00710
u128811851
1432632685
Python
Python3
py
Accepted
60
6720
389
while True: amount, count = map(int, input().split()) if amount == 0 and count == 0: break cards = [i for i in reversed(range(1, amount + 1))] for _ in range(count): p_th, length = map(int, input().split()) swapper = cards[p_th - 1:p_th + length - 1] cards[p_th - 1:p_th...
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,863
s517703309
p00710
u531061483
1432720010
Python
Python
py
Accepted
30
4228
368
# -*- coding:utf-8 -*- import sys def solve(n, r): fuda = [i for i in xrange(1,n+1)] fuda = fuda[::-1] for i in xrange(r): p,c = map(int,raw_input().split()) fuda = fuda[p-1:p+c-1] + fuda[0:p-1] + fuda[p+c-1:n] print fuda[0] if __name__ == "__main__": while 1: n,r = map(int,raw_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,864
s746980018
p00710
u998188826
1441281034
Python
Python3
py
Accepted
60
7612
241
while True: n, r = map(int, input().split()) if (n, r) == (0, 0): break cards = list(range(1, n+1))[::-1] 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,865
s666492398
p00710
u222964743
1450290826
Python
Python
py
Accepted
30
6288
568
while True: n,r = map(int, raw_input().split()) if n==0 and r==0: break else: list = [] for i in range(1,n+1): list.append(i) # print list for i in range(0,r): p, c = map(int, raw_input().split()) hoge = list[len(list)-p+1:len(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,866
s463825555
p00710
u488601719
1451131919
Python
Python
py
Accepted
40
6460
367
while True: n, r = map(int, raw_input().split()) if n == 0 and r == 0: break l = [] for i in range(1, n + 1): l.append(i) for i in range(0, r): p, c = map(int, raw_input().split()) tmp = l[len(l) - p + 1:len(l)] del l[len(l) - p + 1:len(l)] l[len(l) ...
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,867
s161098243
p00710
u488601719
1451132380
Python
Python
py
Accepted
60
6348
302
while True: n, r = map(int, raw_input().split()) if n == 0 and r == 0: break l = range(n, 0, -1) for i in range(r): tmp = [] p, c = map(int, raw_input().split()) for j in range(c): tmp.append(l.pop(p - 1)) l = tmp + l 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,868
s953632371
p00710
u529386725
1452862760
Python
Python
py
Accepted
50
6344
409
while True: n, r = map(int, raw_input().split()) if n == r == 0: break old = range(n, 0, -1) new = range(n, 0, -1) for shuffle in xrange(r): old = list(new) p, c = map(int, raw_input().split()) if p >= 2: for i in xrange(c): new[i] = old[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,869
s625674633
p00710
u440050957
1454177628
Python
Python
py
Accepted
40
6248
396
f = True while f: x = map(int, raw_input().split()) if x == [0, 0]: f = False else: deck = list(range(x[0])) deck.reverse() deck = map((lambda x: x + 1), deck) times = x[1] for i in range(times): p, c = tuple(map(int,raw_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,870
s919239223
p00710
u766163292
1454821694
Python
Python3
py
Accepted
60
7848
518
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array def operation(p, c, cards): return cards[p - 1: p + c - 1] + cards[:p - 1] + cards[p + c - 1:] if __name__ == "__main__": while True: n, r = map(int, input().split()) if n == 0 and r == 0: break else: ...
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,871
s883969909
p00710
u228002579
1461082903
Python
Python
py
Accepted
30
6248
269
while True: 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()) block = card[p-1:p+c-1] del card[p-1:p+c-1] card = block + card 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,872
s114069267
p00710
u858885710
1466499652
Python
Python3
py
Accepted
60
7664
277
while True: n, r = map(int, input().split()) if n == 0 and r == 0: break cards = list(range(1, n+1))[::-1] for _ 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,873
s505249749
p00710
u775586391
1466500886
Python
Python3
py
Accepted
100
7832
329
while True: n,r = tuple(map(int,input().split())) if n==0 and r==0: break l = [n-i for i in range(n)] for i in range(r): p,c = tuple(map(int,input().split())) l1 = [l[i] for i in range(p-1,p+c-1)] l2 = [l[i] for i in range(0,p-1)] l3 = l1+l2 for i in range(p+c-1): l[i] = l3[i] 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,874
s578775131
p00710
u616098312
1466501207
Python
Python3
py
Accepted
60
7524
296
while True: sousa=input().split() sousa=[int(sousa[0]),int(sousa[1])] if sousa==[0,0]:break yama=[] for k in range(sousa[0]):yama.append(k+1) yama=yama[::-1] for r in range(sousa[1]): [p,c]=input().split() [p,c]=[int(p),int(c)] yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-1] print(yama[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,875
s311798600
p00710
u653710476
1466503397
Python
Python3
py
Accepted
60
7580
362
first = input().split() n = int(first[0]) r = int(first[1]) while n != 0 or r != 0: i = 0 card = list(range(1,n+1))[::-1] while i < r: sh = input().split() p, c = list(map(int,sh)) card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:] i = i + 1 print(card[0]) next = inpu...
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,876
s361253970
p00710
u858885710
1466512998
Python
Python3
py
Accepted
60
7600
357
while True: num_cards, num_repeat = map(int, input().split()) if num_cards == 0 and num_repeat == 0: break # ??±??? [n, n-1, ... , 1] cards = list(range(num_cards, 0, -1)) for _ in range(num_repeat): p, c = map(int, input().split()) cards = cards[p-1:p-1+c] + cards[: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,877
s898148512
p00710
u798803522
1468146628
Python
Python3
py
Accepted
70
7664
676
cond = [int(n) for n in input().split(" ")] while True: case = [] cards = [n for n in range(1,cond[0] + 1)] cards.sort(reverse = True) for c in range(cond[1]): case = [int(n) for n in input().split(" ")] case[0] -= 1 #print(cards[case[0]:case[0]+case[1]],cards[case[1]:case[0]+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,878
s230744036
p00710
u798803522
1469808334
Python
Python3
py
Accepted
60
7672
466
cards,trial = (int(n) for n in input().split(" ")) while True: cards = list(reversed([int(n) for n in range(1,(cards)+1)])) for n in range(trial): num,change = (int(n) for n in input().split(" ")) num -= 1 disp = cards[num:num+change] cards[change:change+num] = cards[:num] ...
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,879
s117316266
p00710
u371289566
1470425725
Python
Python3
py
Accepted
60
7676
337
n,r = map(int,input().split()) while n!=0 and r!=0: card = list(range(1,n+1))[::-1] for _ in range(r): p,c = map(int,input().split()) pcard = card[0:p-1] ccard = card[p-1:p-1+c] tmp = card[p-1+c:] nxt = [] nxt.extend(ccard) nxt.extend(pcard) nxt.extend(tmp) card = nxt print(card[0]) n,r = 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,880
s704897575
p00710
u892219101
1473684662
Python
Python3
py
Accepted
60
7652
258
while 1: n,r=map(int,input().split()) if n+r==0: break x=list(range(n,0,-1)) for i in range(r): p,c=map(int,input().split()) y1=x[0:p-1] y2=x[p-1:p-1+c] y3=x[p-1+c:n] x=y2+y1+y3 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,881
s135081209
p00710
u922871577
1480738620
Python
Python
py
Accepted
30
6424
241
while True: N, R = map(int, raw_input().split()) if N == R == 0: break A = range(N, 0, -1) for i in xrange(R): p, c = map(int, raw_input().split()) A = A[p-1:p+c-1] + A[:p-1] + A[p+c-1:] 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,882
s087116411
p00710
u166860661
1480829266
Python
Python
py
Accepted
30
6268
339
while True: l = map(int,raw_input().split()) if l == [0,0]: break else: n = l[0] card = range(n) for i in range(l[1]): l = map(int,raw_input().split()) p = l[0] c = l[1] 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,883
s022818754
p00710
u660912567
1481315762
Python
Python3
py
Accepted
60
7516
217
while True: n,r = map(int,input().split()) if n==r==0: break l = list(range(n,0,-1)) for i in range(r): p,c = map(int,input().split()) l = l[p-1:p+c-1]+l[:p-1]+l[p+c-1:] 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,884
s084272118
p00710
u660912567
1481391833
Python
Python3
py
Accepted
60
7536
217
while True: n,r = map(int,input().split()) if n==r==0: break l = list(range(n,0,-1)) for _ in range(r): p,c = map(int,input().split()) l = l[p-1:p+c-1]+l[:p-1]+l[p+c-1:] 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,885
s517430269
p00710
u633333374
1484464200
Python
Python
py
Accepted
50
6244
280
while True: x, y = map(int,raw_input().split()) lst = range(x,0,-1) if x == 0 and y == 0: break lst = range(x,0,-1) for i in range(y): c = [] a,b = map(int,raw_input().split()) for f in range(b): c.append(lst.pop(a-1)) lst = c + lst 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,886
s903760813
p00710
u842608147
1484645631
Python
Python3
py
Accepted
50
7516
225
while 1: n, r = map(int, input().split()) if n+r < 1 : break *l, = range(n, 0, -1) for i in [0]*r: p, c = map(int, 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,887
s739208391
p00710
u399892098
1485926745
Python
Python
py
Accepted
30
6308
441
while True: str = raw_input() list = str.split() n = int(list[0]) r = int(list[1]) if(n == 0 and r == 0): break n_list = [] for i in xrange(n): n_list.append(i+1) for i in xrange(r): str = raw_input() list = str.split() p = int(list[0]) 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,888
s902948185
p00710
u399892098
1485927268
Python
Python
py
Accepted
40
6276
334
while True: n,r = map(int,raw_input().split()) if(n == 0 and r == 0): break n_list = [] for i in xrange(n): n_list.append(i+1) for i in xrange(r): p,c = map(int, raw_input().split()) n_list = n_list[0:n-(p-1)-c] + n_list[n-(p-1):n] + n_list[n-(p-1)-c:n-(p-1)] pri...
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,889
s761645810
p00710
u078042885
1486314650
Python
Python3
py
Accepted
70
7688
203
while 1: n,r=map(int,input().split()) if n==0: break c=list(range(n,0,-1)) for _ in range(r): a,b=map(int,input().split()) c=c[a-1:a+b-1]+c[:a-1]+c[a+b-1:] print(c[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,890
s487113525
p00710
u661290476
1487319381
Python
Python3
py
Accepted
80
7612
356
while True: n, r = map(int, input().split()) if n == r == 0: break cards = [i + 1 for i in range(n)] for _ in range(r): p, c = map(int, input().split()) swap = [] for i in range(c): swap.append(cards.pop(n - p - i)) for i in swap[::-1]: car...
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,891
s365754577
p00710
u923668099
1488300703
Python
Python3
py
Accepted
50
7652
322
import sys while 1: n, r = map(int, sys.stdin.readline().split()) if (n, r) == (0, 0): break yama = [int(n - i) for i in range(n)] for lp in range(r): p, c = map(int, sys.stdin.readline().split()) p -= 1 yama = yama[p:p + c] + yama[:p] + yama[p + c:] print(yama[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,892
s755030946
p00710
u901080241
1489386657
Python
Python3
py
Accepted
60
7604
245
while True: n,r = map(int ,input().split()) if n==0: break deck = [n-i for i in range(n)] for i in range(r): p,c = map(int, input().split()) p -= 1 deck = deck[p:p+c]+deck[:p]+deck[p+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,893
s162013469
p00710
u399892098
1491797558
Python
Python
py
Accepted
30
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,894