Search is not available for this dataset
name
stringlengths
2
88
description
stringlengths
31
8.62k
public_tests
dict
private_tests
dict
solution_type
stringclasses
2 values
programming_language
stringclasses
5 values
solution
stringlengths
1
983k
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 300010; long long t, n, a[N], b[N], x[N]; int main() { scanf("%lld", &t); while (t--) { long long l, r; scanf("%lld", &n); scanf("%lld%lld", &l, &r); long long tot = r - l + 1; long long high = n - 1, low = 1, mid, s = -1; whi...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; vector<int> func(int n, long long l, long long r) { long long start = 1; long long end = 2 * 1ll * (n - 1); vector<int> ans; if (start <= l && l <= end) { while (l <= r && l <= end) { if (l % 2 == 1) { ans.push_back(1); } else { ans.p...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
# problem 2 def calc(N, index): # find the number when given (N,index) if index == 1 or index == N*(N-1)+1: return 1 else: wave_l = 1 wave_r = N while wave_r-wave_l > 1: M = (wave_l+wave_r)//2 if (2*N-M)*(M-1) < index: wave_l = M ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long mod = 998244353; const int N = 2e5 + 2; int main() { int t; scanf("%d", &t); while (t--) { long long n, l, r; scanf("%lld", &n); scanf("%lld", &l); scanf("%lld", &r); long long cur = 0, val = 2 * (n - 1), ind = 1; while (cur + v...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long n, t, l, r, o, e, pos; long long Find(long long k) { long long t = k; if (t % 2 == 1) t = (t + 1) / 2; else t /= 2; for (long long i = 0; i <= n - 1; i++) { if (n * i - i * (i + 1) / 2 < t && t <= n * (i + 1) - (i + 1) * (i + 2) / 2) retu...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; public class Sol4{ public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { long n = sc.nextInt(); long l = Long.parseLong(sc.next()); long r = Long.parseLong(sc.next()); long idx = 1; ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys input = sys.stdin.buffer.readline t = int(input()) for _ in range(t): n, l, r = map(int, input().split()) s = 1 while l > (n-s)*2: if s == n: break l -= (n-s)*2 r -= (n-s)*2 s += 1 #print(s, l, r) ans = [] while len(ans) <= r: i...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
/* [ ( ^ _ ^ ) ] */ // problem: cf/1334/D // package cf.d; import java.io.*; import java.util.*; public class d { int INF = (int)1e9; long MOD = 1000000007; void solve(InputReader in, PrintWriter out) throws IOException { long n = in.nextLong(); long l = in.nextLong(); long r...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
//make sure to make new file! import java.io.*; import java.util.*; public class D85b{ public static void main(String[] args)throws IOException{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int t = Integer.parseI...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static void solve() throws Exception { long n = sc.nextLong(), l = sc.nextLong(), r = sc.nextLong(), cur = 0; for (long i = 1; i <= n && cur < r; i++) { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class ProblemD { public static InputStream inputStream = System.in; public static OutputStream outputStream = System.out; public static void main(String[] args) { MyScanner scanner = new...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.Collection; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p) { out << '(' << p.first << ", " << p.second << ')'; return out; } template <typename T> ostream& operator<<(ostream& out, vector<T> const& v) { long long l = v.size(); for (long...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; import java.util.*; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastRea...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writa...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; public class Solution{ public static class pair{ int x; int y; } public static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); public String next() { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys input = sys.stdin.buffer.readline t = int(input()) for _ in range(t): n, l, r = map(int, input().split()) s = 1 while l > (n-s)*2+1: if s == n: break l -= (n-s)*2 r -= (n-s)*2 s += 1 #print(s, l, r) if s == n: ans = [n, 1] else:...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void solve() { long long int i, j, n, m, k; long long int l, r; cin >> n >> l >> r; bool var1 = 0; long long int var2 = 0, var = 0; if (r == (n * (n - 1LL)) + 1LL) { var1 = 1; r--; } else { long long int o = 0; while (o < 2) o++; } long lon...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.util.Locale; import java.util.StringTokenizer; public class Solution implements Runn...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.DataInputStream; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchExc...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.ArrayList; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int t=s.nextInt(); StringBuilder sb=new StringBuilder(); for(int i=0;i<t;i++) { int n=s.nextInt(); long l=s.nextLong(); long r=s.nextL...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python2
import sys if sys.subversion[0] == "PyPy": import io, atexit sys.stdout = io.BytesIO() atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue())) sys.stdin = io.BytesIO(sys.stdin.read()) input = lambda: sys.stdin.readline().rstrip() def solve(n, a, b, injections = {}): g = 0 ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
def main(): t=int(input()) for _ in range(t): n,l,r=map(int,input().split()) if l==n*n-n+1: print(1) continue if r==n*n-n+1: r_g=n for i in range(n-1): if l>2*n-2-2*i: l-=2*n-2-2*i else: l...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 9; int main() { long long i, j, m, n, t, l, r, fir, sec; scanf("%lld", &t); while (t--) { scanf("%lld %lld %lld", &n, &l, &r); long long pos = 0; for (i = 1; i <= n; i++) { if (i == n) { pos = -1; break; }...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize "trapv" const int inf1 = 1e9; const long long int inf2 = 1e18; const int N = 100000; using namespace std; int dirs[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; int solve() { long long int n, l, r; cin >> n >> l >> r; if (l == n * (n - 1) + 1) { cout << 1 << "\n"; ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python2
from sys import stdin rints = lambda: [int(x) for x in stdin.readline().split()] for _ in range(int(input())): n, l, r = rints() be, su, cur, ans = 1, 1, n - 1, [] while su + (cur << 1) < l: be += 1 su += (cur << 1) cur -= 1 lst = be for i in range(su, r + 1): if ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; import java.time.Period; public class Main { public static void main(String[] args) throws Exception { int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); long l=sc.nextLong(); long r=sc.nextLong(); int number =1; int i=1; while(l-(n-i)*2>0&&i<n) { n...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 200001; const long long MOD = 1000000007; const long long INF = LLONG_MAX; vector<long long> v; void pre() { v.push_back(1LL); for (long long i = 1; i <= 1e5; i++) v.push_back(i * 2); for (long long i = 1; i < v.size(); i++) v[i] += v[i - 1]; } lon...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long t, n, l, r, q; int main() { scanf("%lld", &t); while (t--) { scanf("%lld%lld%lld", &n, &l, &r); long long now = 0; q = n - 1; bool flag = 0; for (int i = 1; i < n - 1; i++) { if (now + (n - i) * 2 >= l) { q = i; break;...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys input = sys.stdin.readline T = int(input()) for _ in range(T): n, l, r = map(int, input().split()) lb, ub = 0, n while ub - lb > 1: m = (lb + ub) // 2 if m * (2*n-m-1) < l: lb = m else: ub = m i = ub s = lb * (2*n-lb-1) + 1 j = (l - s +...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; import java.math.BigInteger; public class D1334{ static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long cnt[100006]; vector<int> ans; int main() { int tests = 1; int n; long long l, r; scanf("%d", &tests); while (tests--) { ans.clear(); scanf("%d%lld%lld", &n, &l, &r); for (int i = 1; i < n; ++i) cnt[i] = 1ll * (2 * n - i - 1) * i; int s = ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma gcc optimize("O3") #pragma gcc optimize("Ofast") using namespace std; long long n, l, r; long long i, j, t; void nx() { j++; if (j == n + 1) { i++; j = i + 1; } } void print() { if (!t) { cout << i << " "; } else { cout << j << " "; nx(); } t ^= 1; } in...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n, lgrp = 0, rgrp = 0; long long int l, r; cin >> n >> l >> r; for (int k = 1; k <= n - 1; ++k) { if (l <= 2 * (n - k) * 1LL) { lgrp =...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; using vi = vector<ll>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin >> t; while (t--) { ll n, l, r; cin >> n >> l >> r; ll sm = 0; ll iters = 0; ll add = n - 1; if (...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; /** * @author Mubtasim Shahriar */ public class MinEu { public static void m...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
for nt in range(int(input())): w,a,b=map(int,input().split()) if w==2: l=[1,2,1] print (*l[a-1:b]) continue k=w prev=0 for j in range(a,b+1): i=j-prev while k>1: if i<=2*(k-1): if i%2: print (w-k+1,end=" ") else: print (i//2+(w-k+1),end=" ") break else: i-=2*(k-1) prev...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python2
import sys range = xrange input = raw_input t = int(input()) for _ in range(t): n,l,r = [int(x) for x in input().split()] l -= 1 ind = l val = 1 ans = [] while len(ans) < r - l: while ind >= 2 * (n - val) and val < n: ind -= 2 * (n - val) val += 1 if...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
from sys import stdin input = stdin.readline q = int(input()) for _ in range(q): n,l,r = map(int,input().split()) tab = [-1,1] cyk = 0 for i in range(n): cyk += 2*(n-i-1) tab.append(cyk + 1) tab.append(1012809128301279797787789798789798798) i = 0 start = i while True: if tab[i + 1] > l: start = i br...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
t=int(input()) for _ in range(t): n,l,r=map(int,input().split()) L=[0] tt=2*(n-1) for i in range(n): L.append(tt) tt-=2 L[-1]=1 temp=0 ct=r-l+1 c=0 tot=0 for i in range(1,len(L)): if(tot+L[i]<l): tot+=L[i] else: rem=l-tot...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long v[100010]; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; for (int i = 1; i < n; ++i) v[i] = 2 * (n - i); v[n] = 1; for (int i = 1; i <= n; ++i) v[i] += v[i ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; public class ER85D { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); int T = Integer.parseInt(in.readLine()); for (int t ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; import java.util.zip.Adler32; public class Contest1 { static long[]memo; static long[]cc; static long[][]a; static long dp(int idx){ if (idx>=a.length) return 0; if (memo[idx]!=-1) return memo[idx]; long ans = Math.ma...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void solve() { long long n, l, r; cin >> n >> l >> r; long long printed = 0; long long num = 0; while (printed < l) { num++; printed += (2 * (n - num)); if (num == n - 1) { break; } } printed -= 2 * (n - num); num--; vector<int> nums;...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import bisect t=int(input()) for _ in range(t): n,l,r=map(int,input().split()) ans=[] sums=[] tmp=0 for i in range(n-1,0,-1): tmp+=i sums.append(tmp) for i in range(l-1,r): if i%2==0: k=i//2 g=bisect.bisect_right(sums,k) tmp=0 if g==n-1: ans.append(1) else:...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long q, n, i, j, sum, sum2, l, r, pos; cin >> q; while (q--) { cin >> n >> l >> r; sum = 1; for (i = 1; i <= n; i++) { sum2 = max((n - 1 - i), 0 * 1LL) + (n - i) + 1; if (sum + sum2 >= l) { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long maxn = 2e5 + 100; const long long mod = 1e9 + 7; const long long inf = 1e18; long long q, n, l, r, s, t; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; cin >> q; while (q--) { cin >> n >> l >> r; s = 0; t = 1; ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; public class D1334 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); long l = sc.nextLong(), r = sc.nextLong(...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); size_t T; cin >> T; while (T--) { long long int n, l, r; cin >> n >> l >> r; long long int t = 1; long long int k = 1; while (k < l && t != n) { k += 2 * (n - t++); } if (k > l) { k -...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; using ll = long long; long long arr[N]; ll n; int solve(ll x) { if (x == n * (n - 1) + 1) { return 1; } auto p = lower_bound(arr + 1, arr + n + 1, x) - arr - 1; x -= arr[p]; if (x & 1) { return p + 1; } return (p + 1 + x / 2); }...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Solution implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private Sp...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for (int i = (0); i < (t); i += 1) { long long n, l, r; cin >> n >> l >> r; bool z = false; if (r == n * (n - 1) + 1) { r--; z = true; ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int t; ll n, st, dr; cin >> t; while (t--) { cin >> n >> st >> dr; int deAfisat = 0; if (dr == n * (n - 1) + 1) { deAfisat = 1; dr--; } if (st == 1 && dr == 1) { cout << 1 << '\n'; contin...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeSet; /** * Created by Katushka on 11.03.2020. */ public class C { static int[] readArray(int size, InputReader in) { int[] a = new int[size]; for (int i = 0; i < size; i++) { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static Parser parser = new Parser(); public static void main(String[] args) throws IOException { int T = parser.parseInt(); for(int i = 0; i < T; i++){ ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python2
for _ in range(input()): n,l,r = map(int,raw_input().split()) i = 1 s = 0 while s+(n-i)*2<l: s+=(n-i)*2 i+=1 if n==i and s<l: s+=1 break c = 0 j = i+1 while c<(r-l+1): if c==0: for x in range(1,2*(n-i)+1): ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using ll = long long; using namespace std; const ll N = 2e5 + 5, mod = 1e9 + 7; const ll inf = 1e18; struct cmp { bool operator()(pair<int, int> a, pair<int, int> b) { if (a.first == b.first) return a.second < b.second; return a.first > b.first; } }; ll power(ll x, ll p) { ll r = ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys;input=sys.stdin.readline t, = map(int, input().split()) def gen(k): return [k+(i+1)//2 if i%2 else k for i in range(2*(n-k))] for _ in range(t): n, s, e = map(int, input().split()) k, sm = 0, 0 while sm < s and k < n-1: k += 1 sm += 2*(n-k) if sm < s: k+=1 k...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
from collections import * import sys try: inp = raw_input except: inp = input def err(s): sys.stderr.write('{}\n'.format(s)) def ni(): return int(inp()) def nl(): return [int(_) for _ in inp().split()] def solve(): n, L, R = nl() L -= 1 R -= 1 SM = 0 out = [] for i in range(1, n)...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long INF = 1e13 + 5; const int mod = 1e9 + 7; const int maxn = 1e5 + 5; long long n, l, r, s[maxn]; int calc(long long x) { if (x > s[n - 1]) return 1; long long a = lower_bound(s + 1, s + n, x) - s; long long b = x - s[a - 1]; if (b % 2) return a; ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys d = [] def bins(k, n): l = 0 r = n-2 while l != r: mid = (l+r+1)//2 if d[mid] <= k: l = mid else: r = mid-1 # print("debug:", l) ex = k - d[l] if ex &1: f = ex//2 return f + l + 2 else: return l+1 for q in...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.util.stream.*; import java.io.*; import java.math.*; public class Main { static boolean FROM_FILE = false; static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { if (FROM_FILE) { t...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.Scanner; public class D { public static void main(String[] args) { Scanner file = new Scanner(System.in); int inputs = file.nextInt(); while(inputs-->0) { int n = file.nextInt(); long l = file.nextLong(); long r = file.nextLong(); long[] changes = new long[n+1]; changes[1] = 2*(...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
for t in range(int(input())): n,l,r=map(int,input().split()) b=1 for i in range(1,n): a=b b+=2*(n-i) if l<b: break x,y=i,(l-a)//2+i+1 b=(l-a)%2 for _ in range(r-l): if b: print(y,end=" ") y+=1 if y==n+1: x+=1 y=x+1 else: print(x,end=" ") ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
/* *created by Kraken on 02-05-2020 at 14:27 */ //package com.kraken.cf.practice; import java.util.*; import java.io.*; public class D1334 { public static void main(String[] args) { FastReader sc = new FastReader(); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); long l = sc...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long a[1000006]; long long n; map<long long, long long> mp; int main() { long long Q; cin >> Q; while (Q--) { cin >> n; long long l, r; cin >> l >> r; a[0] = (n - 1) * 2; long long k = a[0] - 2; long long po = 0; for (int i = 1; i < 10...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
for _ in range(int(input())): n, l, r = map(int, input().split()) cursum = 0 curn = n - 1 while curn > 0 and (cursum + (curn << 1)) < l: cursum += curn << 1 curn -= 1 fix = n - curn d = False i = fix nexti = fix + 1 # print(cursum, l, i, nexti) for _ in range(curs...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; public class D { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bu...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Prac{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public InputReader(InputStream st) { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; // 21:35.396 + 2:22.250 + 2:29.637 public class cf1334d { public static void main(String[] args) throws IOException { int t = ri(); while(t --> 0) { int n = rni(); long...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys input = sys.stdin.buffer.readline t = int(input()) for _ in range(t): n, l, r = map(int, input().split()) s = 1 while l > (n-s)*2+1: #if s == n: #break l -= (n-s)*2 r -= (n-s)*2 s += 1 #print(s, l, r) if s == n: ans = [n, 1] els...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys from collections import defaultdict from copy import copy R = lambda t = int: t(input()) RL = lambda t = int: [t(x) for x in input().split()] RLL = lambda n, t = int: [RL(t) for _ in range(n)] def solve(): n, l, r = RL() if l == n*(n-1)+1: print(1) return l -= 1 r -= 1 D = ((2*n-1)**2-4*l...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; public class A { public static void main(String ar[]) throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int t=Integer.parseInt(br.readLine()); for(int p=0;p<t;p++) { ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long f(long long N, long long x) { return (2 * N - 1 - x) * x; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long N; cin >> N; long long l, r; cin >> l >> r; long long ng = 0, ok = N; while...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("O3", "unroll-all-loops") using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long ml = kk * kk; const long long mod = ml * kk + 7; const long long inf = ml * ml * ml + 7; long long n, l, r; bool viv = false; vector<long long> v; void solve...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("-O3") using namespace std; const double PI = acos(-1); long long gcd() { return 0ll; } template <typename T, typename... Args> T gcd(T a, Args... args) { return __gcd(a, (__typeof(a))gcd(args...)); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cou...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long T; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> T; while (T--) { long long n, l, r; cin >> n >> l >> r; long long g = n * (n - 1) + ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T> T InvMod(T a, T b, T &x, T &y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = InvMod(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; } long long fact(long long n) { if (n == 1) return 1; return (n % ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
#Code by Sounak, IIESTS #------------------------------warmup---------------------------- import os import sys import math from io import BytesIO, IOBase from fractions import Fraction import collections from itertools import permutations from collections import defaultdict from collections import deque import threadi...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Itwazonce */ public class...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> const long long int maxn = 1e10; const long long mod = 1e9 + 7; using namespace std; long long int power(long long int a, long long int b) { long long int res = 1; while (b > 0) { if (b % 2 == 1) res = res * a; a = a * a; b = b / 2; } return res; } long long po(long long x, ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int mn = 1 * (int)(1e5) + 10; const int mod = 1 * (int)(1e9) + 7; const int mm = 1 * (int)(1e3) + 10; const int base = 1 * (int)(1e9); const bool aNs = 0; int tt, ntest = 1; void docfile() { ios::sync_with_stdio(false); cin.tie(nullptr); if (ifstream("test.inp")...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); srand(time(NULL)); ; long long int p; cin >> p; while (p--) { long long int a, b, c, d, e, l, r, f, cnt = 1; vector<long long int> Ans; cin >> a >> l >> r; f = l; long lo...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Practice { public static long mod = (long) Math.pow(10, 9) + 7; public static long mod2 = 998244353; public static int tt = 1; public static ArrayList<Integer> p...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; import java.util.Arrays; import java.io.IOException; import java.io.InputStream; import java.util.Comparator; import java.util.PriorityQueue; /** * Built using CHelper plug-in * Actual...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.util.*; import java.io.*; public class Main { static FastReader in=new FastReader(); static StringBuilder Sd=new StringBuilder(); static List<Integer>Gr[]; static long Mod=998244353; static Map<Integer,Integer>map=new HashMap<>(); public static void main(String [] args) { //Di...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long n, l, r; long long num; vector<long long> ans; bool intersect(long long l1, long long r1, long long l2, long long r2) { return min(r1, r2) >= max(l1, l2); } void cal(long long left) { if (left == n) return; if (intersect(l, r, num + 1, num + 2 * (n - left)))...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; for (int t = 0; t < T; ++t) { long long n, l, r; cin >> n; cin >> l; cin >> r; long long curr_position = 0; for (long long i1 = 1; i1 < n; ++i1) { long long x = cu...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.*; public class Task { public static void main(String[] args) throws Exception { new Task().go(); } PrintWriter out; Reader in; BufferedReader br; Task() throws IOException { try { //br = new BufferedReader( new FileReader("in...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") int T; int n, L; long long l, r; vector<int> v = {1, 2, 1}; long long cyc(int x) { if (x == n - 1) return 3; long long res = 2 * (n - x); return res; } void printcyc(int nr, long long start, int len) { if (nr == n - 1) { int step = ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
CASES = int(input()) answers = [] while (CASES): CASES -= 1 num, begin, end = [int(x) for x in input().split(" ")] sequence = [] index = 1 tempB = begin tempE = end temp = 2*(num - index) while (tempB > temp and index < num): tempB -= temp tempE -= temp index...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
//package codeforces.educational85; import java.io.*; import java.util.*; public class MinimumEulerCycle { public static void main(String[] args) { // try { // FastScanner in = new FastScanner(new FileInputStream("src/input.in")); // PrintWriter out = new PrintWriter(new FileOutputStr...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
import sys input = sys.stdin.buffer.readline for t in range(int(input())): n,l,r = map(int,input().split()) for i in range(l,min(2*(n-2)+1,r) + 1): print('1' if i & 1 else i//2 + 1 , end = ' ') n_set = n set_idx = 2*(n-2) + 2 while(n_set > 2): ls = l - set_idx + 1 rs = ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python2
from sys import stdout from bisect import bisect_left as bl # large output out = [] def solve(l, r, n): if l == n * (n - 1) + 1: out.append('1') return occs = [i for i in xrange(n - 1, 0, -1)] pref = [occs[i] for i in xrange(n - 1)] for i in xrange(1, n - 1): pref[i] = pref[i...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
python3
def find(a): global k, tot if a > n * (n - 1): return 1 while a > tot + (n - k) * 2: tot += (n - k) * 2 k += 1 if a & 1: return k return (a - tot) // 2 + k for _ in range(int(input())): n, l, r = map(int, input().split()) global k, tot k = 1 tot = 0 ...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedInputStream; import java.util.Scanner; public class Main { private static Scanner sc = new Scanner(new BufferedInputStream(System.in)); public static void main(String[] args) { work(); } private static void work() { int t = sc.nextInt(); for (int i = 0;...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner scn = new Scanner(System.in); OutputWriter out = new OutputWriter(System.out); // Always print a trailing "\n" and close the OutputWriter as shown...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.PriorityQueue; import java.util.Stack; import java.util...
1334_D. Minimum Euler Cycle
You are given a complete directed graph K_n with n vertices: each pair of vertices u β‰  v in K_n have both directed edges (u, v) and (v, u); there are no self-loops. You should find such a cycle in K_n that visits every directed edge exactly once (allowing for revisiting vertices). We can write such cycle as a list of...
{ "input": [ "3\n2 1 3\n3 3 6\n99995 9998900031 9998900031\n" ], "output": [ "1 2 1 \n1 3 2 3 \n1 \n" ] }
{ "input": [ "1\n2 2 3\n", "1\n4 13 13\n", "1\n3 1 1\n", "10\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n2 1 3\n", "1\n3 7 7\n", "1\n25 30 295\n", "1\n4 12 13\n", "5\n3 7 7\n4 13 13\n5 21 21\n6 31 31\n7 42 43\n", "1\n5 4 4\n" ], "output": [ "2 1 \n", ...
CORRECT
cpp
#include <bits/stdc++.h> using namespace std; class Solution { public: void solve() { long long n, l, r; cin >> n >> l >> r; long long rngIdx = 0; long long begin = 0, end = n; while (begin < end) { long long mid = begin + (end - begin) / 2; if (2 * n * mid - mid * (mid + 1) >= l) { ...