Skip to content

Commit 74713f8

Browse files
committed
Graph Based Problem 3
1 parent 89779c8 commit 74713f8

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CP/Codeforces Round #457 (Div. 2)/prob2.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,36 @@
44
if k < len(a):
55
print 'No'
66
quit()
7+
#print(a)
78
s = a[-1]
89
c = 0
910
while len(a) + c < k:
1011
if a and s == a[-1]:
1112
c += 1
1213
a.pop()
14+
#print(a)
1315
c = c * 2
1416
s -= 1
1517
t = len(a) + c - k
1618
a.reverse()
1719
b = 0
20+
#print(t,a,c,s)
1821
if t:
1922
while t:
2023
c -= 2
2124
t -= 1
2225
b += 1
26+
#print("loop1")
2327
if not a:
2428
c -= 1
2529
a.append(s)
30+
#print("loop2")
31+
#print(c)
2632
while c > 1:
2733
c -= 2
2834
b += 1
2935
a.extend([a.pop() - 1] * 2)
36+
#print("loop3")
3037
a = [s + 1] * b + [s] * c + a
3138
print 'Yes'
3239
for x in a:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
n, m = map(int, raw_input().split())
2+
t = k = 100000007
3+
print 2, (k if n != 2 else 2)
4+
print 1, n, 2
5+
k -= 2
6+
for i in range(2, n):
7+
print 1, i, k / (n - 2) + (k % (n - 2) if i == 2 else 0)
8+
u, v = 2, 2
9+
for i in range(n - 1, m):
10+
v += 1
11+
if v > n:
12+
u += 1
13+
v = u + 1
14+
print u, v, t

CP/Codeforces Round #457 (Div. 2)/prob4.cpp

Whitespace-only changes.

0 commit comments

Comments
 (0)