description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) a = [] ans = [0] * n for i in range(n): q, w = map(int, input().split()) a.append([q, w, i]) a.sort() ans[a[0][2]] = 1 m = a[0][1] for i in range(1, n): m = max(a[i - 1][1], m) if a[i][0] <= m: ans...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
n = int(input()) for i in range(n): li = [] origli = [] q = int(input()) for j in range(q): a, b = input().split(" ") a, b = int(a), int(b) li.append([a, b]) origli.append([a, b]) li.sort() newli = [li[0]] i = 1 s1 = set() s2 = set() s1.add(tuple(l...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR LIST VAR V...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def add(Dict, key, value): if key in Dict: Dict[key].append(value) else: Dict[key] = [value] def Coloring(n, data): assert n == len(data), "Error parsing data and its length" allCord = set() opening = dict() closing = dict() reference = dict() for i in range(n): ...
FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR FUNC_DEF VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for c in range(int(input())): N = int(input()) counter = 0 segments = [] for n in range(N): l, r = map(int, input().split()) segments.append([[l, r], counter]) counter += 1 segments.sort() ans = [-1] * N rightBound = segments[0][0][1] valid = -1 for i in range...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST LIST VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) ans = [0] * n cc = 0 l = [] for xx in range(n): a, b = map(int, input().split()) qqq = [a, b, xx] l.append(qqq) l4 = sorted(l, key=lambda x: x[0]) c = 1 x = 2 zz = 0 kk = 0 f = 0 for i in range(n - 1):...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n, intersections, curr_group = int(input()), 0, 1 l = [[[int(x) for x in input().split()], i, curr_group] for i in range(n)] l.sort(key=lambda x: x[0]) current_group_max = l[0][0][1] for i in range(1, n): if current_group_max >= l[i][0][0]: int...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) a = [] for i in range(n): x, y = map(int, input().split()) a.append([x, y, i]) a.sort() g1 = a[0][0] g11 = a[0][1] g2 = a[1][0] g22 = a[1][1] b = [0] * n z = a[-1][2] b[z] = 2 maxr = -1 f = False for i...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys q = int(sys.stdin.readline()) for _ in range(q): n = int(sys.stdin.readline()) a = [] for i in range(n): l, r = map(int, sys.stdin.readline().split()) a.append([l, r, i]) a.sort() ans = [2] * n maxx = a[0][1] ans[a[0][2]] = 1 for i in range(1, n): maxx...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for t in range(T): N = int(input()) segs = [] for i, n in enumerate(range(N)): seg = [int(x) for x in input().split()] + [i] segs.append(seg) segs.sort(key=lambda x: x[0]) clas = 1 nots = [2] * len(segs) A, B, _ = segs[0] for seg in segs: C, D, id...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR B...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin t = int(input()) for _ in range(t): n = int(input()) l = [(list(map(int, stdin.readline().split())) + [i]) for i in range(n)] l.sort() rb = l[0][1] res = [1] * n res[l[0][2]] = 2 flag = False for v in l[1:]: if v[0] > rb: flag = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def do_intersect(a, b): return min(a[1], b[1]) >= max(a[0], b[0]) for _ in range(int(input())): n = int(input()) inps = [tuple(map(int, input().split())) for _ in range(n)] org = [pair for pair in inps] inps.sort() sets = [inps[0]] for i in range(1, n): merged = False for j...
FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR L...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for _ in range(t): a, d, f = [], dict(), 0 n = int(input()) a = [list(map(int, input().split())) for _ in range(n)] b = sorted(a) cur = b[0][1] for l, r in b: if l > cur: f = 1 break else: d[l, r] = 1 if r > cur: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR IF VAR V...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
q = int(input()) for i in range(q): n = int(input()) ilist = [] for j in range(n): ilist.append(list(map(int, input().rstrip().split()))) ilist[j].append(j) ilist.sort() seglist = [2] * n seglist[ilist[0][2]] = 1 goodvalue = -1 currentmax = ilist[0][1] for k in range(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) l = [] for i in range(n): a, b = map(int, input().split()) l.append((a, 0, i)) l.append((b, 1, i)) g = sorted(range(n)) l.sort(key=lambda x: x[0]) t = [(2) for i in range(n)] k = 0 test = 0 count = 0 ind...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR F...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) a = [] for i in range(n): a.append([list(map(int, input().split())), i]) ans = [-1] * n a.sort() f = -1 maxr = -1 for i in range(n - 1): maxr = max(a[i][0][1], maxr) if maxr < a[i + 1][0][0]: f = i ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CAL...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys input = sys.stdin.readline n = int(input()) for i in range(n): x = int(input()) a = [(list(map(int, input().split())) + [j]) for j in range(x)] a.sort() g1 = 0 ans = [0] * x g1 = a[0][1] ans[a[0][2]] = 1 for j in range(1, x): if g1 < a[j][0]: ans[a[j][2]] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUM...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def C(): q = int(input()) for _ in range(q): n = int(input()) tuples = [] for i in range(n): ab = [int(x) for x in input().split()] tuples.append((ab[0], ab[1], i)) tuples.sort() sol = ["-1"] * n r_act = tuples[0][1] flag = 0 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in [0] * int(input()): n = int(input()) t = [2] * n m = g = 0 for l, r, i in sorted([*map(int, input().split()), i] for i in range(n)): g += l > m m = max(m, r) t[i] -= g & 1 print(*(t, [-1])[g < 2])
FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUM...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) otr = [] for item in range(n): otr.append(tuple(int(x) for x in input().split())) sortr = [(0, 0)] * 2 + sorted(otr) dic = {} dic[0, 0] = 1 c1 = 0 c2 = 0 maxy = 0 for item in range(2, len(sortr)): if maxy >= sor...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER NUMBER FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) final = [] for k in range(t): n = int(input()) skl = [] for i in range(n): a, b = map(int, input().split()) skl.append((a, -1, i)) skl.append((b, 1, i)) skl.sort() m = 0 ans = ["0"] * n for i, p in enumerate(skl): if m == 0 and i != 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUM...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for test in range(t): n = int(input()) arr = [] for i in range(n): l, r = map(int, input().split()) arr.append([l, r, i]) arr = sorted(arr, key=lambda item: item[0]) i = 1 ans = [0] * n ans[arr[0][2]] = 1 mm = arr[0][1] f = 0 while i < n: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) segs = [] for i in range(n): l, r = map(int, input().split()) segs.append((l, r, i)) segs.sort(key=lambda x: x[1]) suffixMinX = [-1] * n suffixMinX[n - 1] = segs[n - 1][0] for i in range(n - 2, -1, -1): suffixMinX[i] = mi...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin, stdout Q = int(input()) for i in range(Q): N = int(input()) pair = [] for j in range(N): arr = [int(x) for x in stdin.readline().split()] pair.append(arr) data = sorted(pair, key=lambda e: (e[0], e[1])) cur = 0 flag = 0 ans = {} j = 0 ans[data[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
query = int(input()) for _ in range(query): n = int(input()) array = [] for i in range(n): a, b = map(int, input().split()) array.append([a, b, i]) array.sort() max1 = array[0][1] flag = False answer = [0] * n answer[array[0][2]] = 1 for i in range(1, n): if n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) x = [] for j in range(n): l, r = map(int, input().split(" ")) x.append((l, r)) y = sorted(x, key=lambda x: x[0]) j = 1 f = 0 max = y[0][1] while j < len(y): if y[j][0] > max: q = y[j][0] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in [0] * int(input()): n = int(input()) a = [] for i in range(n): l, r = map(int, input().split()) a += (l, 0, i), (r, 1, i) a.sort() g, c, t = 2, 0, [0] * n for x, m, i in a: if m: c -= 1 else: if c == 0: g ^= 3 ...
FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER BIN_OP LIST NUMBER VAR FOR VAR VAR VAR VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin, stdout t = int(stdin.readline()) for _ in range(t): n = int(stdin.readline()) arr = dict() for i in range(n): r = [int(x) for x in stdin.readline().split()] arr[i] = r keys = list(arr.keys()) keys.sort(key=lambda x: arr[x][0]) ans = [(0) for i in range(n)]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBE...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) a = [] for i in range(n): l, r = list(map(int, input().split())) a.append([l, r, i]) a.sort() ma = a[0][1] b = -1 for i in range(n): if ma < a[i][0]: b = i break else: ma ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER F...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys input = sys.stdin.readline Q = int(input()) for test in range(Q): n = int(input()) LR = [(list(map(int, input().split())) + [i]) for i in range(n)] LR.sort() GR1 = [LR[0][0], LR[0][1]] for i in range(1, n): l, r, _ = LR[i] if r < GR1[0] or l > GR1[1]: ANS = i ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
q = int(input()) qarr = [] for i in range(0, q): intnum = int(input()) intnumarr = [] for j in range(0, intnum): size = input() size = size.split() for k in range(0, 2): size[k] = int(size[k]) size.append(j) intnumarr.append(size) qarr.append(intnumarr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def solution(x): distrib = [-1] * len(x) distrib[x[0][2]] = 1 maxR = x[0][1] k = 1 while k < len(x) and x[k][0] <= maxR: distrib[x[k][2]] = 1 maxR = max(maxR, x[k][1]) k += 1 if k == len(x): return [-1] for i in range(k, len(x)): distrib[x[i][2]] = 2 ...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN LIST NUMBER F...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) l = [] for j in range(n): b, r = map(int, input().split()) l.append([b, r, j, 0]) l.sort(key=lambda x: x[0]) k = 0 m = l[0][1] while k < n - 1 and m >= l[k + 1][0]: if l[k + 1][1] > m: m = l[k + 1][1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
class Pair: def __init__(self, s, i): b = s.split(" ") self.left = int(b[0]) self.right = int(b[1]) self.num = i self.group = 0 t = int(input()) for j in range(0, t): n = int(input()) arr = [] for i in range(0, n): arr.append(Pair(input(), i)) arr1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
N = int(input()) for i in range(N): T = int(input()) newtable = [] for i in range(T): a, b = map(int, input().split()) newtable.append((a, b, i)) newtable.sort() sta = 0 ans = [-1] * T flag = 0 t = 0 i = 0 while i < T: s, t, k = newtable[i] if t > ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) a = sorted(list(map(int, input().split())) + [i] for i in range(n)) ans = [0] * n group = 1 maxx = a[0][1] for l, r, i in a: if group == 1 and maxx < l: group = 2 if r > maxx: maxx = r ans[i] = group ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR VAR IF VAR NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for t in range(T): l = [] N = int(input()) ans = [0] * N for n in range(N): a, b = map(int, input().split()) l.append((a, b, n)) l.sort() ans[l[0][2]] = 1 MAX = l[0][1] for i in range(1, N): if l[i][0] > MAX: break ans[l[i][2]]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) l = [] for i in range(0, n): a, b = map(int, input().split()) l.append((min(a, b), max(a, b), i)) l.sort() grp = 1 prev = int(0) j = int(0) ans = [] for curr, r, i in l: if grp == 2: ans.append((i, 2))...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for l00p in range(int(input())): a = [] ans = [] for i in range(int(input())): ans.append(1) a.append(tuple(list(int(x) for x in input().split()) + [i])) a.sort(key=lambda tup: tup[0]) flag = 0 NO = 1 right = a[0][1] for l, r, pos in a: if flag: ans[po...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIG...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) ar = [] for i in range(n): ar.append(list(map(int, input().split())) + [i]) ar.sort(key=lambda x: x[0]) su = 0 flag = False ma = ar[0][1] for i in range(1, n): if ar[i][0] > ma: ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for _ in range(t): n = int(input()) dp = [(2) for i in range(n)] lst = [(0) for i in range(2 * n)] count = 0 for i in range(n): u, v = map(int, input().split()) lst[count] = [u, -1, i] lst[count + 1] = [v, 1, i] count += 2 lst.sort() total = 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST V...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys from itertools import accumulate input = sys.stdin.readline t = int(input()) for _ in range(t): n = int(input()) lr = [(list(map(int, input().split())) + [i]) for i in range(n)] lr.sort() mx = [lr[0][1]] for i in range(1, n): mx.append(max(mx[-1], lr[i][1])) flg = 0 ans =...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXP...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def ii(): return int(input()) def li(): return list(map(int, input().split())) def mi(): return map(int, input().split()) for _ in range(ii()): N = ii() ar = [(li() + [i]) for i in range(N)] ar.sort() last = ar[0][0] ans = [2] * N for l, r, i in ar: if l > last: ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASS...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
class Interval: def __init__(self, le, ri): self.le = le self.ri = ri self.group = -1 def __repr__(self): return f"({self.le}, {self.ri})" T = int(input()) for t in range(T): N = int(input()) a = [None] * N for i in range(N): a[i] = Interval(*map(int, inpu...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN STRING VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for _ in range(T): n = int(input()) events = [] results = [(0) for i in range(n)] fail = False for i in range(n): l, r = map(int, input().split()) events.append((l, 0, i)) events.append((r, 1, i)) events.sort() cnt = 0 cur_seg = 1 for _, t, i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NU...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for test in range(t): n = int(input()) ans = ["1" for i in range(n)] start, end = dict(), dict() for i in range(n): a, b = list(map(int, input().split())) if a in start: start[a].append(i + 1) else: start[a] = [i + 1] if i + 1 in e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR BI...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def solve(coords, ans): n = len(coords) coords1 = coords[:] coords1.sort() groups = [] min_val, max_val = coords1[0][0], coords1[0][1] for i in range(1, n): x, y = coords1[i][0], coords1[i][1] if x <= max_val: max_val = max(max_val, y) elif len(groups) == 0: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSI...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for _ in range(T): n = int(input()) s = [] for k in range(n): l, r = [int(i) for i in input().split()] s.append([l, 1, k]) s.append([r, 2, k]) s.sort() u = [2] * n o = set() for i in s: u[i[2]] = 1 if i[2] not in o: o.add(i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR EXPR FUNC_CALL VAR LIST VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_O...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for i in range(T): n = int(input()) X = [] for j in range(n): l, r = map(int, input().split()) X.append([j, l, r]) X = sorted(X, key=lambda x: x[1]) Y = ["2"] * n s = -1 rmax = X[0][2] Y[X[0][0]] = "1" for i in range(1, n): if X[i][1] > rmax: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) l = [] for i in range(n): x, y = map(int, input().split()) l.append((x, y, i)) l.sort() l1 = l[0][0] r1 = l[0][1] g = 1 groups = [0] * n for i in range(n): if l[i][0] > r1: g = 2 groups[l[i][2]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) sobs = [] for j in range(n): a, b = map(int, input().split()) sobs.append([[a, -1], j]) sobs.append([[b, 1], j]) sobs.sort() counts = 0 passed = [] success = [] alls = [(0) for q in range(n)] succeed = False...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST LIST VAR NUMBER VAR EXPR FUNC_CALL VAR LIST LIST VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) a = sorted(list(map(int, input().split())) + [i] for i in range(n)) cut = a[0][1] ans = [2] * n ok = False for i in range(n): if cut < a[i][0]: for k in range(i): ans[a[k][2]] = 1 ok = True ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
MOD = 10**9 + 7 I = lambda: list(map(int, input().split())) (t,) = I() while t: t -= 1 (n,) = I() a = [2] * n l = [] for i in range(n): l.append(I() + [i]) l.sort() mn = l[0][0] mx = l[0][1] i = 0 while i < n and l[i][0] <= mx: mx = max(mx, l[i][1]) a[l[i]...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR LIST VAR EXPR FUNC_C...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys test = int(input()) for irene in range(test): a = [] n = int(input()) ans = ["1"] * n for i in range(n): a.append((*map(int, input().split()), i)) a.sort() tnt, mn = -1, 0 for l, r, i in a: if l > mn: tnt += 1 mn = max(mn, r) if tnt % 2...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR VAR ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin, stdout input = stdin.readline t = int(input()) for _ in range(t): n = int(input()) pts = [] for i in range(n): a, b = map(int, input().split()) pts.append((a, b, i)) pts = sorted(pts) mark = [(1) for i in range(n)] ok = 0 mi = pts[0][0] ma = pts[0]...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR AS...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for i in range(T): n = int(input()) inp = [] temp = [] for j in range(n): a, b = [int(u) for u in input().split()] inp.append([a, b]) temp.append([a, b]) inp.sort() check = 0 begin = inp[0][0] end = inp[0][1] for j in range(n): if inp[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUM...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys inf = float("inf") def get_array(): return list(map(int, sys.stdin.readline().split())) def get_ints(): return map(int, sys.stdin.readline().split()) def input(): return sys.stdin.readline() for _ in range(int(input())): n = int(input()) l = sorted(get_array() + [i] for i in rang...
IMPORT ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def get(): return list(map(int, input().split(" "))) def d(): n = int(input()) t = [] for i in range(n): t.append(get() + [i]) t.sort() i = 0 r = t[0][1] ans = ["2"] * n while i < n and t[i][0] <= r: ans[t[i][2]] = "1" r = max(r, t[i][1]) i += 1 ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST STRING VAR WH...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for _ in range(T): n = int(input()) seg = [] for s in range(n): l, r = [int(x) for x in input().split()] seg.append((l, r)) pos = {} for i in range(n): if seg[i] in pos: pos[seg[i]].append(i) else: pos[seg[i]] = [i] seg.sor...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): q = int(input()) lst = [] for c in range(q): a, b = map(int, input().split()) lst.append([a, b, c]) lst.sort() p = -1 m = lst[0][1] for c in range(len(lst) - 1): m = max(m, lst[c][1]) if m < lst[c + 1][0]: p = c ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP F...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for i in range(T): n = int(input()) seg = [] for i in range(n): seg.append([int(i) for i in input().split()] + [i]) seg.sort() gp = [1] * n ans = [-1] * n end = seg[0][1] for i in range(n): if seg[i][0] <= end: gp[i] = gp[i - 1] else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys t = int(input()) for i in range(t): n = int(input()) a = [] for j in range(n): l, r = map(int, sys.stdin.readline().split()) a.append([l, r, j]) c = [2] * n a.sort() j = 0 m1 = a[0][1] while j < n: p = a[j][0] q = a[j][1] if p <= m1: ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASS...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) while t: d = [] lol = 0 lo = 0 prev = 0 ind = -1 cou = 0 n = int(input()) for i in range(n): l, r = map(int, input().split()) d.append((l, r)) d1 = sorted(d) for i in d1: l, r = i[0], i[1] cou += 1 if cou == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for _ in range(t): n = int(input()) a = [] f = 0 for i in range(n): l, r = map(int, input().split()) a.append([l, r, i]) a.sort(key=lambda x: x[0]) rm = a[0][1] for i in range(n): if a[i][0] > rm: b = a[i] f = 1 bre...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys q = int(input()) for i in range(0, q): n = int(input()) l = [] r = [] for j in range(0, n): l1, r1 = map(int, input().split()) l += [l1] r += [(l1, r1)] r.sort() l1 = -1 rm = -1 for j in range(0, n - 1): if r[j][1] > rm: rm = r[j][1...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NU...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for _ in range(t): n = int(input()) segments = [] for i in range(n): l, r = map(int, input().split()) segments.append([l, r, i]) segments.sort() ans = [(1) for i in range(n)] prev = 1 maxR = 0 ansOfMaxR = 1 for i in range(n): cl, cr, ci = segm...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSI...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
q = int(input()) for i in range(q): rec = [] n = int(input()) flag = False ans = [1] * n for j in range(n): l, r = map(int, input().split()) rec.append((l, r, j)) rec = sorted(rec) k = rec[0][1] for a in range(n): if k < rec[a][0]: flag = True ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for t in range(T): n = int(input()) l = [0] * n r = [0] * n for i in range(n): l[i], r[i] = [int(x) for x in input().split()] gr = [0] * n sl = [*range(n)] sl.sort(key=lambda x: l[x]) tr = r[sl[0]] g = 1 for i in range(n): tl = l[sl[i]] if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FUN...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in [0] * int(input()): n = int(input()) t = [0] * n g = c = k = 0 a = sorted( sum( zip( *( ((l, 1, i), (r + 1, 0, i)) for (l, r), i in ((map(int, input().split()), i) for i in range(n)) ) ), ...
FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_CA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for _ in range(t): n = int(input()) l = [] for i in range(n): li, ri = map(int, input().split()) l.append([li, ri, i, 1]) l.sort(key=lambda x: x[0]) r = l[0][1] for i in range(1, n): if l[i][0] <= r: l[i][3] = 1 r = max(r, l[i][1])...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin t = int(input()) res = [] for _ in range(t): n = int(input()) xs = [(list(map(int, stdin.readline().strip().split())) + [i]) for i in range(n)] xs.sort() rs = [1] * n q = 1 ml, mr = 0, xs[0][1] for l, r, i in xs: if q == 1 and l <= mr: mr = max(mr, ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR LIST VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def solve(): n = int(input()) points = [] for i in range(n): l, r = [int(x) for x in input().split()] points.append((l, r, i)) points.sort() border = -1 cnt_sets = 1 cur_set = 0 ans = [(0) for _ in range(n)] for l, r, pos in points: if (l > border and border <...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR IF VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for i in range(int(input())): l = [] n = int(input()) for j in range(n): x, y = map(int, input().split()) l.append((min(x, y), max(x, y), j)) ans = [] group = " 1" prev = int(0) j = int(0) l.sort() for cur, b, c in l: if group == " 2": ans.append((...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for j in range(int(input())): n = int(input()) s = [] ind = [int(0)] * n for i in range(n): s.append(tuple(list(map(int, input().split())) + [i])) s.sort() mx = max(s[0][0], s[0][1]) ind[s[0][2]] = 1 for i in range(1, len(s)): if mx < min(s[i][0], s[i][1]): br...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_C...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def solve(n, lrs): elements = enumerate(lrs) elements = list(sorted(elements, key=lambda x: x[1][1])) i, j = 0, n - 1 g_1 = elements[i][1] g_2 = elements[j][1] a_group_index = [elements[i][0]] b_group_index = [elements[j][0]] while len(a_group_index) + len(b_group_index) < n: whi...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR LIST VAR VAR NUMBER ASSIGN VAR LIST VAR VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR WHILE BIN_OP V...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for t in range(T): n = int(input()) arr = [[None for x in range(3)] for y in range(n)] for i in range(n): user_in = input() a, b = user_in.split(" ") a = int(a) b = int(b) arr[i] = [a, b, i] arr.sort() val = 0 d = [None for x in range(n)] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN V...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for _ in range(t): q = int(input()) d = dict() main = [] rese = [] for i in range(q): l, r = map(int, input().split()) d[hash((l, r))] = -1 main.append([l, r]) rese.append([l, r]) main.sort() new_l = main[0][0] new_r = main[0][1] d[has...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR EXPR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
import sys input = sys.stdin.readline T = int(input()) for _ in range(T): n = int(input()) lr = [((i,) + tuple(map(int, input().split()))) for i in range(n)] lr.sort(key=lambda k: k[2]) l_min = 10**6 for i in range(n - 1, 0, -1): l_min = min(l_min, lr[i][1]) div = lr[i - 1][2] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def check(data): n = len(data) s = sorted(zip(data, range(n))) m = s[0][0][1] left = set() for i, r in enumerate(s): left.add(r[1]) if i == len(s) - 1: return "-1" m = max(m, r[0][1]) if s[i + 1][0][0] > m: break res = [("1" if j in left el...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for i in range(0, T): n = int(input()) L = [] dp = [0] * n for j in range(0, n): l, r = map(int, input().split()) L.append((l, r, j)) L = sorted(L) temp = -1 ed = L[0][1] for j in range(1, len(L)): if L[j][0] > ed: temp = j ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) arr = [] for j in range(n): arr.append(tuple(map(int, (input() + " " + str(j)).split()))) arr.sort() grp = [(1) for j in range(n)] grp[n - 1] = 2 pos = False highest = -1 for j in range(n - 1): highest = max(highest...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR A...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) data = [] for q in range(n): x, y = map(int, input().split()) data.append([x, y, q]) data.sort() ans = [-1] * n ans[data[0][2]] = 0 pivot = 0 prev = data[0][1] for q in range(1, n): if data[q][0] <= prev: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin t = int(stdin.readline().strip()) for _ in range(t): n = int(stdin.readline().strip()) arr = [] for i in range(n): l, r = list(map(int, stdin.readline().split())) arr.append([l, r, i]) arr = sorted(arr, key=lambda x: (x[0], x[1], x[2])) mydict = dict() mydi...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUM...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
T = int(input()) for _ in range(T): n = int(input()) snts = [] for i in range(n): l, r = list(map(int, input().split())) snts.append([l, r, i]) snts = sorted(snts, key=lambda x: x[0]) res = [1] rs, v, ids = [snts[0][1], -1], 0, [snts[0][2]] for i in range(1, n): l, r,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST NUMBER ASSI...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) a = [] for i in range(n): x, y = list(map(int, input().split())) a.append([x, y, i]) a.sort() i = 0 m = a[i][1] b = ["2"] * n while i < n and m >= a[i][0]: b[a[i][2]] = "1" m = max(m, a[i][1]) i += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP L...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
q = int(input()) while q > 0: q = q - 1 L = [] n = int(input()) for i in range(n): L.append(tuple(map(int, input().split()))) d = {} ind = 0 for i in L: if i not in d: d[i] = [] d[i].append(ind) ind += 1 S = sorted(L) r = S[0][1] i = 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EX...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in [0] * int(input()): n = int(input()) a = [] for i in range(n): a += zip(map(int, input().split()), (i, n)) a.sort() g = c = 0 t = [2] * n for x, i in a: if i < n: c += 1 g += c == 1 t[i] -= g % 2 else: c -= 1 ...
FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR IF VAR VAR VAR NUMBER VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def sol(): def f(el): return el[0] am = int(input()) arr = [0] * am out = [0] * am for i in range(am): arr[i] = list(map(int, input().split())) + [i] arr.sort(key=f) lType = 0 endAt = arr[0][1] count = [1, 0] out[arr[0][2]] = 1 for i in range(1, am): ...
FUNC_DEF FUNC_DEF RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER N...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def main(): t = int(input()) for _ in range(t): n = int(input()) segments = [] for i in range(n): l, r = map(int, input().split()) segments.append((l, r, i)) segments.sort(key=lambda x: (x[0], -x[1])) flag = False ret = [0] * n ret[...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) lis = [] for i in range(n): a, b = map(int, input().split()) lis.append([a, b, i + 1]) lis.sort() ans = [2] * (n + 1) ans[0] = 0 j = lis[0][1] ans[lis[0][2]] = 1 for i in range(1, n): a, b, c = lis[i] if j...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def intersect(seg, e): X1 = seg[0] X2 = seg[1] X3 = e[0] X4 = e[1] if max(X1, X2) < min(X3, X4): return False return True t = int(input()) for i in range(t): n = int(input()) l = [0] * n group = ["0"] * n for i in range(n): l[i] = list(map(int, input().split()))...
FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin t = int(input()) while t > 0: n = int(input()) li = [] for i in range(n): l, r = [int(x) for x in stdin.readline().split()] li.append((l, r, i)) li2 = sorted(li) ans = [2] * n ans[li2[0][2]] = 1 d = li2[0][1] count = 0 for i in range(1, len(li2)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for tc in range(t): n = int(input()) l = [] for i in range(n): a, b = map(int, input().split()) l.append([i, a, b]) l = sorted(l, key=lambda x: x[1]) last = l[0][1] i = 0 while i < n: if l[i][1] > last: break last = max(last, l[i][...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR N...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
for _ in range(int(input())): n = int(input()) ra = [] mn = [1] * n for i in range(n): x, y = map(int, input().split()) ra.append((x, y, i)) ra.sort() l = ra[0][0] r = ra[0][1] g = 1 for i in ra: if i[0] > r: g = 2 mn[i[2]] = g r = ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMB...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
n = int(input()) for t in range(n): k = int(input()) samples = [] for i in range(k): samples.append(tuple(map(int, input().split()))) samples = sorted(enumerate(samples), key=lambda x: x[1]) tick = 1 ans = [1] group_end = samples[0][1][1] for si in range(1, len(samples)): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSI...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
from sys import stdin inp = lambda: stdin.readline().split() for _ in range(int(stdin.readline())): n = int(stdin.readline()) mas = [tuple(map(int, inp())) for i in range(n)] d = {} for i, x in enumerate(mas): if d.get(x) == None: d[x] = [] d[x].append(i) lst = sorted(ma...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VA...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for i in range(t): n = int(input()) llist = [] rlist = [] index = [] groups = [] for j in range(n): l, r = map(int, input().split()) llist.append(l) rlist.append(r) index.append(j) groups.append(0) llist, rlist, index = zip(*sorted(zip...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
L = 0 R = 1 def main(): buf = input() T = int(buf) n = [] lr = [] for i in range(T): buf = input() n.append(int(buf)) lr.append([]) for j in range(n[i]): buf = input() buflist = buf.split() lr[i].append([int(buflist[0]), int(bufli...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
t = int(input()) for ti in range(t): n = int(input()) lri = [None for _ in range(n)] for _ in range(n): li, ri = map(int, input().split()) lri[_] = li, ri, _ lri.sort() t = [None for _ in range(n)] ct, t[lri[0][2]], eg = 1, 1, lri[0][1] for i in range(1, n): if lri[i]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR ...
There are $n$ segments $[l_i, r_i]$ for $1 \le i \le n$. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group. To optimize ...
def answer(n, p): p.sort(key=lambda x: x[0]) l = [[p[0][0], p[0][1]]] ans = [2] * n ans[p[0][2]] = 1 for i in range(1, n): if p[i][0] <= l[-1][1]: l[-1][1] = max(l[-1][1], p[i][1]) if len(l) == 1: ans[p[i][2]] = 1 else: l.append([p[...
FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST LIST VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR NUMBER IF FUNC_CALL ...
Tattah's youngest brother, Tuftuf, is new to programming. Since his older brother is such a good programmer, his biggest dream is to outshine him. Tuftuf is a student at the German University in Cairo (GUC) where he learns to write programs in Gava. Today, Tuftuf was introduced to Gava's unsigned integer datatypes. G...
def datatypes(x, answer): for i in range(1, n): if x[i] < 2 * x[i - 1] and x[i] != x[i - 1]: answer = "YES" break print(answer) n = int(input()) x = list(map(int, input().split())) x.sort() answer = "NO" datatypes(x, answer)
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR STRING EXPR FUNC_CALL VA...