message
stringlengths
2
49.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
446
108k
cluster
float64
13
13
__index_level_0__
int64
892
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find a cycle in a directed graph G(V, E). Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 1,000 * si ≠ ti Input A directed graph G is given in the following format: |V| |E| s0 t0 s1 t1 : s|E|-1 t|...
instruction
0
58,825
13
117,650
No
output
1
58,825
13
117,651
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find a cycle in a directed graph G(V, E). Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 1,000 * si ≠ ti Input A directed graph G is given in the following format: |V| |E| s0 t0 s1 t1 : s|E|-1 t|...
instruction
0
58,826
13
117,652
No
output
1
58,826
13
117,653
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Find a cycle in a directed graph G(V, E). Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 1,000 * si ≠ ti Input A directed graph G is given in the following format: |V| |E| s0 t0 s1 t1 : s|E|-1 t|...
instruction
0
58,827
13
117,654
No
output
1
58,827
13
117,655
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You're given a tree consisting of n nodes. Every node u has a weight a_u. It is guaranteed that there is only one node with minimum weight in the tree. For every node u (except for the node with...
instruction
0
58,864
13
117,728
No
output
1
58,864
13
117,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You're given a tree consisting of n nodes. Every node u has a weight a_u. It is guaranteed that there is only one node with minimum weight in the tree. For every node u (except for the node with...
instruction
0
58,865
13
117,730
No
output
1
58,865
13
117,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya is an unexperienced programming contestant. Recently he has come across the following problem: You are given a non-directed graph which consists of n nodes and m edges. Your task is to de...
instruction
0
59,163
13
118,326
No
output
1
59,163
13
118,327
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,561
13
119,122
"Correct Solution: ``` # -*- coding: utf-8 -*- import sys from collections import Counter def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d...
output
1
59,561
13
119,123
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,562
13
119,124
"Correct Solution: ``` N = int(input()) A = list(map(int, input().split())) A.sort() maxv1 = A[-1] maxv2 = A[-2] if maxv1 != maxv2: print("Impossible") exit() K = maxv1 if K % 2 == 0: for i in range(K // 2): for j in range(2): if K - i in A: A.remove(K - i) e...
output
1
59,562
13
119,125
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,563
13
119,126
"Correct Solution: ``` from heapq import heappush,heappop,heapify from collections import deque,defaultdict,Counter import itertools from itertools import permutations,combinations import sys import bisect import string import math import time #import random def I(): return int(input()) def MI(): return map(int...
output
1
59,563
13
119,127
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,564
13
119,128
"Correct Solution: ``` import math #import numpy as np import queue from collections import deque,defaultdict import heapq as hpq from sys import stdin,setrecursionlimit #from scipy.sparse.csgraph import dijkstra #from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def main(): n = int...
output
1
59,564
13
119,129
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,565
13
119,130
"Correct Solution: ``` def main(): from collections import Counter as ct n = int(input()) a = list(map(int, input().split())) c = ct(a) min_a = min(a) max_a = max(a) if min_a == 1: if c[min_a] == 1: pass elif a == [1, 1]: print("Possible") ...
output
1
59,565
13
119,131
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,566
13
119,132
"Correct Solution: ``` from collections import Counter N = int(input()) a = [int(i) for i in input().split()] def solve() : cnt = list(Counter(a).items()) cnt.sort() if cnt[0][1] == 1 and cnt[-1][0] != 2 * cnt[0][0] : return 'Impossible' if cnt[0][1] == 2 and cnt[-1][0] != 2 * cnt[0][0] -...
output
1
59,566
13
119,133
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,567
13
119,134
"Correct Solution: ``` from collections import Counter n = int(input()) a = list(map(int, input().split())) c = Counter(a) m = max(a) flag = True if m%2 == 0: for i in range(1,m+1): if i<m//2: if c[i]!=0: flag = False break elif i==m//2: if...
output
1
59,567
13
119,135
Provide a correct Python 3 solution for this coding contest problem. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for e...
instruction
0
59,568
13
119,136
"Correct Solution: ``` from collections import Counter N = int(input()) A = list(map(int,input().split())) ctr = Counter(A) maxa = max(A) mina = min(A) def ok(): if mina != (maxa+1)//2: return False if maxa%2: if ctr[mina] != 2: return False else: if ctr[mina] != 1: return False ...
output
1
59,568
13
119,137
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,569
13
119,138
Yes
output
1
59,569
13
119,139
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,570
13
119,140
Yes
output
1
59,570
13
119,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,571
13
119,142
Yes
output
1
59,571
13
119,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,572
13
119,144
Yes
output
1
59,572
13
119,145
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,573
13
119,146
No
output
1
59,573
13
119,147
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,574
13
119,148
No
output
1
59,574
13
119,149
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,575
13
119,150
No
output
1
59,575
13
119,151
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Aoki loves numerical sequences and trees. One day, Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tr...
instruction
0
59,576
13
119,152
No
output
1
59,576
13
119,153
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,780
13
119,560
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys input=sys.stdin.readline T = int(input()) ver = set() #pdb.set_trace() for _ in range(T): ver.clear() n, m = map(int, input().split()) n *= 3 edge = [] for __ in range(m): u, v = map(int, input().split()) if u...
output
1
59,780
13
119,561
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,781
13
119,562
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline T = int(input()) for _ in range(T): n, m = map(int, input().split()) v = [True] * (3 * n + 1) e = [0] * n ptr = 0 for i in range(1, m + 1): a, b = map(int, input().split()) ...
output
1
59,781
13
119,563
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,782
13
119,564
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline def main(): tes = int(input()) for testcase in [0]*tes: n,m = map(int,input().split()) new = [True]*(3*n) res = [] for i in range(1,m+1): u,v = map(in...
output
1
59,782
13
119,565
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,783
13
119,566
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline sys.setrecursionlimit(100000) def getN(): return int(input()) def getList(): return list(map(int, input().split())) import math def prmatch(ans): print("Matching") print(*ans) def solve...
output
1
59,783
13
119,567
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,784
13
119,568
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline T = int(input()) for _ in range(T): n, m = map(int, input().split()) v = set(range(1, 3 * n + 1)) e = [] for i in range(1, m + 1): a, b = map(int, input().split()) if a in ...
output
1
59,784
13
119,569
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,785
13
119,570
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys input = sys.stdin.readline T=int(input()) for testcases in range(T): n,m=map(int,input().split()) EDGE=[[0,0]]+[list(map(int,input().split())) for i in range(m)] USED=[0]*(3*n+1) count=0 ANS=[] for i in ...
output
1
59,785
13
119,571
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,786
13
119,572
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` from sys import stdin input = stdin.readline T = int(input()) for _ in range(T): n, m = [int(i) for i in input().split()] ind_edg_v = [True]*(3*n+1) ind_edg_e = [0]*n num_edg = 0 for j in range(m): ed...
output
1
59,786
13
119,573
Provide tags and a correct Python 3 solution for this coding contest problem. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an endpoint. A set of vertices is called an indepe...
instruction
0
59,787
13
119,574
Tags: constructive algorithms, graphs, greedy, sortings Correct Solution: ``` import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline t = int(input()) for _ in range(t): n, m = map(int, input().split()) edge = [] for i in range(m): u, v = map(int, input().split()) ...
output
1
59,787
13
119,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an e...
instruction
0
59,788
13
119,576
Yes
output
1
59,788
13
119,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an e...
instruction
0
59,789
13
119,578
Yes
output
1
59,789
13
119,579
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an e...
instruction
0
59,790
13
119,580
No
output
1
59,790
13
119,581
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an e...
instruction
0
59,791
13
119,582
No
output
1
59,791
13
119,583
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an e...
instruction
0
59,792
13
119,584
No
output
1
59,792
13
119,585
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a graph with 3 ⋅ n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices. A set of edges is called a matching if no two edges share an e...
instruction
0
59,793
13
119,586
No
output
1
59,793
13
119,587
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get c...
instruction
0
60,103
13
120,206
No
output
1
60,103
13
120,207
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get c...
instruction
0
60,104
13
120,208
No
output
1
60,104
13
120,209
Provide tags and a correct Python 3 solution for this coding contest problem. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs ...
instruction
0
60,373
13
120,746
Tags: dfs and similar, dsu, graphs Correct Solution: ``` __author__ = 'Darren' class DisjointSet: def __init__(self, n): self.array = [-1] * n def union(self, x, y): rx, ry = self.find(x), self.find(y) if rx == ry: # in the same set already return False # Merge...
output
1
60,373
13
120,747
Provide tags and a correct Python 3 solution for this coding contest problem. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs ...
instruction
0
60,374
13
120,748
Tags: dfs and similar, dsu, graphs Correct Solution: ``` def dfs(v, graph): isloop = False lo, ro = graph # expand right pr, r = lo, ro expand_right = [] while True: if len(v[r]) == 1: break else: nr1, nr2 = v[r] rn = nr1 if nr1 != pr else nr2 expand_right.append(rn) if rn == lo: # we found lo...
output
1
60,374
13
120,749
Provide tags and a correct Python 3 solution for this coding contest problem. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs ...
instruction
0
60,375
13
120,750
Tags: dfs and similar, dsu, graphs Correct Solution: ``` n, m = map(int, input().split()) g = [[] for i in range(n)] for i in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 g[u].append(v) g[v].append(u) if any(len(g[v]) > 2 for v in range(n)): print('NO') exit() used = [False] * n ...
output
1
60,375
13
120,751
Provide tags and a correct Python 3 solution for this coding contest problem. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs ...
instruction
0
60,376
13
120,752
Tags: dfs and similar, dsu, graphs Correct Solution: ``` def dfs(v, comp): used[v] = comp for u in graph[v]: if not used[u]: dfs(u, comp) n, m = map(int, input().split()) graph = [[] for i in range(n)] for i in range(m): v, u = map(int, input().split()) graph[v - 1].append(u - 1) ...
output
1
60,376
13
120,753
Provide tags and a correct Python 3 solution for this coding contest problem. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs ...
instruction
0
60,377
13
120,754
Tags: dfs and similar, dsu, graphs Correct Solution: ``` import sys from array import array # noqa: F401 def input(): return sys.stdin.buffer.readline().decode('utf-8') def NO(): print('NO') exit() def YES(edges): edges.sort() print('YES') print(len(edges)) for e in edges: pri...
output
1
60,377
13
120,755
Provide tags and a correct Python 3 solution for this coding contest problem. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is called interesting, if each of its vertices belongs ...
instruction
0
60,378
13
120,756
Tags: dfs and similar, dsu, graphs Correct Solution: ``` class DisjointSet: def __init__(self, n): self.array = [-1] * n def union(self, x, y): rx, ry = self.find(x), self.find(y) if rx == ry: return False if self.array[rx] < self.array[ry]: self.array[r...
output
1
60,378
13
120,757
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is calle...
instruction
0
60,379
13
120,758
No
output
1
60,379
13
120,759
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is calle...
instruction
0
60,380
13
120,760
No
output
1
60,380
13
120,761
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is calle...
instruction
0
60,381
13
120,762
No
output
1
60,381
13
120,763
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Hexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life «interesting graph and apples». An undirected graph is calle...
instruction
0
60,382
13
120,764
No
output
1
60,382
13
120,765
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has got an undirected graph consisting of n vertices and m edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connec...
instruction
0
60,656
13
121,312
Tags: constructive algorithms, graphs Correct Solution: ``` n, m = map(int, input().split()) min_res = max(0, n - 2 * m) l, r = min_res, n + 1 def check(tmp): t = n - tmp return t * (t - 1) // 2 >= m while l != r - 1: tmp = (l + r) // 2 if check(tmp): l = tmp else: r = tmp print...
output
1
60,656
13
121,313
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya has got an undirected graph consisting of n vertices and m edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connec...
instruction
0
60,657
13
121,314
Tags: constructive algorithms, graphs Correct Solution: ``` import sys import math n,m=map(int,input().split()) if(m==0): print(n,n) elif(n==1): print(n,n) else: store=[0]*(n+1) if(m>=(n*(n-1))//2): print("0","0") else: for i in range(2,n+1): store[i]+=(i*(i-1))//2 if(m>stor...
output
1
60,657
13
121,315