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
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.math.BigInteger; import java.util.Scanner; public class Moving_Points { public static void main(String args[]) { Scanner reader = new Scanner(System.in); int n = reader.nextInt(); int[] x = new int[n]; for (int i = 0; i < n; i++) x[i] = reader.nextInt(); ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import static java.lang.Math.*; import java.util.Scanner; public class onebalgo { static long minsum=0; static int n; static dot[] overwrite=new dot[n]; public static boolean samepace(dot i,dot j) { if(i.vel==j.vel) return true; else return false; } public static boolean waitornot(dot i,dot j) { ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; struct abc { long long first; long long second; }; bool comp(abc a, abc b) { return a.second < b.second; } int main() { long long n, cnt = 0; cin >> n; abc a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i].second; for (int i = 1; i <= n; i++) { cin >> a[i...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
// "It does not matter how slowly you go as long as you do not stop." - Confucius #include <bits/stdc++.h> using namespace std; /* author : Roshan_Mehta motto : Time Management,Consistency,Patience!! */ #define int long long void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} // void __print...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python2
from sys import stdin from collections import * class order_tree: def __init__(self, arr): self.n = len(arr) self.r = n << 1 self.tree = [[0, 0] for _ in range(self.n * 2)] self.order = defaultdict(int, {arr[i]: i for i in range(self.n)}) # get interval[l,r) def query(self...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long int N = 300009; const long long int mod = 1000000007; long long int n; vector<pair<long long int, long long int>> v; const long long int inf = 0; struct Node { Node *l = 0, *r = 0; long long int lo, hi, mset = inf, madd = 0, val = 0; Node(long long int...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
numberofpoints=int(input()) initcoords=input().split(" ") speeds=input().split(" ") initcoords=tuple(map(int,initcoords)) speeds=tuple(map(int,speeds)) def twopoints(coords,velos): firstv=velos[0] secondv=velos[1] firstc=coords[0] secondc=coords[1] dif=abs(firstv-secondv) nextdif=abs((firstc+fi...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 15; int tot = 1, N; const int L = -2e8; const int R = 2e8; struct Node { int l, r, num; long long sum; Node() { l = 0, r = 0, num = 0, sum = 0; } } E[maxn * 40]; struct Point { long long x, v; bool operator<(const Point &T) const { return x ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<cmath> #include<ctime> #include<vector> #include<queue> #include<stack> #include<list> #include<set> #include<map> #include<utility> #include<algorithm> using namespace std; #define FOR(i,a,b) for(register int i=(a);i<(b...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os, Container const& x) { os << "{ "; for (auto& y : x) os << y << " "; return os << "}"; } template <class X, class Y> ostream& o...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { std::cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); std::cerr...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
//package psa.minrazdalja; import java.util.ArrayList; import java.util.Scanner; // Import the Scanner class import javax.swing.plaf.synth.SynthSpinnerUI; public class minrazdalja { static class MinStruktua { private int x; private float v; public MinStruktua(int x, int v) { this.x = x; this.v = v; ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; struct dd { int gt; int x; int v; }; vector<dd> a; struct Data { long long sum; int sl; }; Data it[200009 * 8]; Data ans; long long res; void update(int i, int l, int r, int pos, int data) { if (l > pos || r < pos) return; if (l == r) { it[i].sum = ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys input = sys.stdin.readline n=int(input()) X=list(map(int,input().split())) V=list(map(int,input().split())) XV=[(X[i],V[i]) for i in range(n)] compression_dict_x={a: ind for ind, a in enumerate(sorted(set(X)))} compression_dict_v={a: ind+2 for ind, a in enumerate(sorted(set(V)))} XV=[(compression_dict_x[...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int n; void update(vector<long long> &b, int ind, int numb) { for (int i = ind; i < b.size(); i = ((i + 1) | i)) b[i] += numb; } int Sum(vector<long long> &b, int ind) { int ans = 0; for (int i = ind; i >= 0; i = ((i + 1) & i) - 1) ans += b[i]; return ans; } int sum...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; using namespace std::chrono; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; ///find_by_order, order_of_key typedef long long ll; typedef long double...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; public class Moving_Points { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for (int i=0;i<n;i++) a[i] = scan.nextInt(); for (int i=0;i<n;...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long maxn = 200005; map<long long, long long> g; map<long long, long long> invG; long long tree[4][maxn]; long long sum(long long k, long long t) { long long res = 0; for (long long i = k; i >= 1; i -= i & -i) res += tree[t][i]; return res; } void add(long ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class Round624F { public static class node{ int pos; int neg; long negsum; long possu...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n], v[n]; for (int i = 0; i < n; i++) { cin >> x[i]; } for (int i = 0; i < n; i++) { cin >> v[i]; } int d = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (v[i] * v[j] > 0 && x[i]...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Reader; import java.util.ArrayList; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.StringTokenizer;...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.lang.*; import java.io.*; public class F { public static void main (String[] args) throws java.lang.Exception { new Solution(); } } class Solution { Scanner scanner; public Solution() { scanner = new Scanner(System.in); while (scanner.hasNext()) { run_case(); } } pri...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n=int(input()) x=[int(x) for x in input().split()] v=[int(x) for x in input().split()] d=0 for i in range(n): for j in range(i+1, n): if v[i]==v[j]: d+=abs(x[i]-x[j]) elif v[i]<v[j] and x[i]<x[j]: d+=abs(x[i]-x[j]) elif v[j]>v[i] and x[j]>x[i]: d+=abs(x[i]...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(nam...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m, pos, s[N][2], v[N]; long long tot; struct node { long long x, v; } a[N]; bool cmp(node x, node y) { return x.x < y.x; } int lowbit(int x) { return x & (-x); } void update(int x, int val) { while (x <= n) { s[x][0]++; s[x][1] += v...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; vector<long long> x, v; int idX(int val) { return (lower_bound(x.begin(), x.end(), val) - x.begin()); } int idV(int val) { return (lower_bound(v.begin(), v.end(), val) - v.begin()); } struct FenwickTree { vector<long long> bit; int n; FenwickTree(int n) { this->n ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, len; int bit[N][2]; void add(int x, int val) { while (x <= n) { bit[x][0]++; bit[x][1] += val; x += x & -x; } } long long query(int x, int k) { long long res = 0; while (x) { res += 1LL * bit[x][k]; x -= x & -x; }...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; pair<int, long long> a[200005]; int t[200005]; map<int, int> M; pair<int, long long> f[200005]; int n; void update(int gt) { int x = M[gt]; while (x <= n) { f[x] = {f[x].first + 1, f[x].second + gt}; x += x & -x; } } pair<int, long long> get(int x) { int cnt...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.*; import java.util.*; import java.util.concurrent.TimeUnit; public class f624 implements Runnable{ public static void main(String[] args) { try{ new Thread(null, new f624(), "process", 1<<26).start(); } catch(Exception e){ System.out.println(e); ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class MovingPoints { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System....
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os, Container const& x) { os << "{ "; for (auto& y : x) os << y << " "; return os << "}"; } template <class X, class Y> ostream& o...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void fio() {} void pti() { double timeuse = clock() * 1000.0 / CLOCKS_PER_SEC; cerr << "Timeuse " << timeuse << "ms" << endl; } void end() { exit(0); } namespace io { const int SIZ = 55; int que[SIZ], op, qr; char ch; template <class I> inline void gi(I& w) { ch = get...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; const int N = 2e5 + 5, mny = -1e9; vector<vector<pair<int, pair<int, int> > > > seg(4 * N); long long n, ans; pair<int, int> p[N]; vector<pair<int, pair<int, int> > > merge( vector<pair<int, pair<int, int> > > l, vector<pair<int, pair<int,...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) x = list(map(int, input().split())) v = list(map(int, input().split())) d = [(x[i], v[i]) for i in range(n)] d.sort(key=lambda x: x[0]) ans = 0 for i in range(1, n): for j in range(i): if d[j][1] < d[i][1]: ans += d[i][0] - d[j][0] print(ans)
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; constexpr int maxN = 2e5 + 43; int n; vector<pair<int, int>> point; vector<int> val, cnt, cval; int LSOne(int k) { return (k & (-k)); } void update(vector<int>& f, int pos, int val) { for (; pos <= n; pos += LSOne(pos)) f[pos] += val; } long long rsq(vector<int>& f, int p...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#pragma GCC optimize("O3") #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define pb push_back #define pf pu...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
//#pragma comment(linker, "/stack:200000000") #include<bits/stdc++.h> using namespace std; #define LL long long #define ULL unsigned long long const LL INF=1LL<<60; const double PI = acos(-1.0); typedef pair<int,int> pii; typedef pair<LL,LL> pll; typedef vector<int> vi; typedef vector<LL> vl; typedef vector<pii> vii;...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
def subCost(array): cost = 0 for i in array: for j in array: cost += abs(i[0] - j[0]) return cost // 2 def f(left, right): cost = 0 for r in right: for l in left: if r[0] > l[0]: cost+=r[0]-l[0] else: break retu...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int num[800005], m; long long b[200005], sum[200005], cnt[200005], tr[800005]; struct node { int x, v; bool operator<(const node t) const { return x < t.x; } } a[200005]; int lsh(long long x) { return lower_bound(b + 1, b + 1 + m, x) - b; } void build(int l, int r, int ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; constexpr int maxN = 2e5 + 43; int n; vector<pair<int, int>> point; vector<int> val, cnt, cval; int LSOne(int k) { return (k & (-k)); } void update(vector<int>& f, int pos, int val) { for (; pos <= n; pos += LSOne(pos)) f[pos] += val; } long long rsq(vector<int>& f, int p...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.Scanner; import java.util.Stack; import java.util.Arrays; import java.util.HashMap; import java.util.Comparator; public class F{ // static final int max = 10000; static class Pair{ int x; int speed; public String toString(){ return "[" + x + ", " + speed + "]"; } } static class FenvikTr...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int las[5001]; int fa[5001]; int mark[5001]; int dep[5001]; signed main() { int T; scanf("%d", &T); while (T--) { int n, d; scanf("%d%d", &n, &d); if (d > n * (n - 1) / 2) { printf("NO\n"); continue; } memset(dep, 0, sizeof(dep)); m...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys,math,itertools from collections import Counter,deque,defaultdict from bisect import bisect_left,bisect_right from heapq import heappop,heappush,heapify, nlargest from copy import deepcopy mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin....
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
/* K.D. Vinit |,,| */ #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; void solve() { int n; cin>>n; ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; } template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; } template <typename tuple<long long, long long, long long> > struct SegmentTree { using F =...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; void solve(); int main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); solve(); return 0; } inline long long max(long long a, int b) { return max(a, (long long)b); } inline long long max(int a, long long b) { return max((long long)a, b); } inline lo...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys input=sys.stdin.readline def getsum(BITTree,i): s = 0 while i > 0: s += BITTree[i] i -= i & (-i) return(s) def updatebit(BITTree , n , i ,v): while i <= n: BITTree[i] += v i += i & (-i) n=int(input()) x=[int(i) for i in input().split() if i!='\n'] v=[int(i) fo...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
n = int(input()) x = [int(a) for a in input().split()] v = [int(a) for a in input().split()] sum = 0 for i in range(1, n): for j in range(i, n): if x[j] < x[j-1]: temp = x[j] x[j] = x[j-1] x[j-1] = temp temp = v[j] v[j] = v[j-1] v[j-1] ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
//package psa.minrazdalja; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class minrazdalja { /** * Uvozena abstraktna funk...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.io.*; import java.math.BigInteger; public class Solution { static class Pair<A,B>{ A parent; B rank; Pair(A parent,B rank) { this.rank=rank; this.parent=parent; } } // static int find(Pair pr[],int i) // { // ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.awt.*; import java.io.*; import java.io.IOException; import java.util.*; import java.text.DecimalFormat; public class Exam { public static long mod = (long)Math.pow(10, 9)+7 ; public static double epsilon=0.00000000008854;//value of epsilon public static InputReader sc = new InputReader(System.in); ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 200000; long long BIT1[200001]; long long BIT2[200001]; int cnt1[200001]; int cnt2[200001]; map<int, int> r, l; pair<int, int> arr[200001]; int n; void upd1(int idx, long long val) { for (; idx <= N; idx = (idx | (idx + 1))) { BIT1[idx] += val; cnt1[...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC optimize("unroll-loops") #pragma warning(disable : 4996) #include<iostream> #include<string> #include<algorithm> #include<vector> #include<queue> #include<map> #include<math.h> #include<iomanip> #incl...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, ans = 0; cin >> n; vector<pair<int, int> > v(n); for (int i = 0; i < n; i++) { cin >> v[i].first; } for (int i = 0; i < n; i++) cin >> v[i].second; sort(v.begin(), v.end()); ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; bool isprime(long long int n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } vector<long long int> prime; ...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
import java.util.*; import java.io.*; import java.lang.reflect.Array; public class template { final static int MOD = 1000000007; final static int intMax = 1000000000; final static int intMin = -1000000000; final static int[] DX = { 0, 0, -1, 1 }; final static int[] DY = { -1, 1, 0, 0 }; static int T; static c...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { if (!y) return x; return gcd(y, x % y); } const long long MOD = 1e9 + 7; int inf = 1e9 + 7; long long INF = 2e18 + 9; long long power(long long x, long long y) { long long res = 1ll; x %= MOD; if (x == 0) return 0; while...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> p2; ll x[200005]; p2 t[800005],lazy[800005]; vector<p2> v1,v2; vector<ll> v; p2 add(p2 a,p2 b){ return {a.first+b.first,a.second+b.second}; } void update(ll v,ll tl,ll tr,ll pos,ll val){ if(tl==tr){ t[v]=add(t[v],{val,1})...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
//package psa.minrazdalja; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class minrazdalja { /** * Uvozena abstraktna funk...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
java
//package com.netease.music.codeforces.round624.div3; import java.util.Arrays; import java.util.Scanner; /** * Created by dezhonger on 2020/2/27 */ public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[][] xv...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; long long bit[4][200005]; void update(long long k, long long val, long long p) { while (k < 200005) { bit[p][k] += val; k += (k & (-k)); } } long long query(long long k, long long p) { long long s = 0; while (k > 0) { s += bit[p][k]; k -= (k & (-k));...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const long long N = 200005; long long n; pair<long long, long long> x[N]; long long m; map<long long, long long> mp; long long ans; struct seg { long long vals[2 * N]; long long q(long long l, long long r) { long long ret = 0; for (l += m, r += m; l < r; l >>= 1...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; int mpow(int base, int exp); void ipgraph(int m); void dfs(int u, int par); const long long int mod = 1000000007; const int N = 3e5, M = N; vector<int> g[N]; int a[N]; int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
python3
import sys input=sys.stdin.readline t=int(input()) import math def build(arr,cur_pos,start,end,seg,pre): if(start==end): seg[cur_pos]=([arr[start]],[arr[start][0]]) else: mid=(start+end)//2 build(arr,2*cur_pos+1,start,mid,seg,pre) build(arr,2*cur_pos+2,mid+1,end,seg,pre) seg[cur_pos]=merge(seg[2*cur_pos+1]...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int bit[N]; void add(int p, int v) { for (p += 2; p < N; p += p & -p) bit[p] += v; } int query(int p) { int r = 0; for (p += 2; p; p -= p & -p) r += bit[p]; return r; } int n; pair<int, int> p[N]; long long l[N], r[N]; int ql[N], qr[N]; int ma...
1311_F. Moving Points
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ...
{ "input": [ "3\n1 3 2\n-100 2 3\n", "2\n2 1\n-3 0\n", "5\n2 1 4 3 5\n2 2 2 3 4\n" ], "output": [ "3\n", "0\n", "19\n" ] }
{ "input": [], "output": [] }
IN-CORRECT
cpp
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; const long long INF = 1e18; const long double PI = 4 * atan((long double)1); const int INFTY = 1e7; class FenwickTree2D { private: map<pair<long long, long long>, long long> m; public: FenwickTree2D() { m.clear(); } void update(int r, 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; long long n; int tc = 0; int solve(); int main() { ios_base::sync_with_stdio(0); if (tc < 0) { cout << "TC!\n"; cin.ignore(1e8); } else if (!tc) cin >> tc; while (tc--) solve(); return 0; } int solve() { long long l, r; cin >> n >> l >> r; 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; void solve() { int64_t n, l, r; cin >> n >> l >> r; l--, r--; int64_t cnt = 0; int64_t start = 1; int64_t num = n - 1; while (start < n) { if (l < cnt + 2 * num && r >= cnt) { for (int64_t i = 0; i < 2 * num; i++) { if (l <= cnt + i && cnt + ...
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 D { PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok; HashMap<List<Long>, Long> map = new HashMap<>(); public 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; int T; int N; long long L, R; int main() { scanf("%d", &T); while (T--) { scanf("%d%lld%lld", &N, &L, &R); if (L == R && L == 1LL * N * (N - 1) + 1) { printf("1\n"); continue; } long long i = N - 1; for (; i; i--) { if (L > 2 * 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.util.*; import java.io.*; public class Solution{ static PrintWriter out=new PrintWriter(System.out); public static void main (String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String[] input=br.readLine().trim().split(" "); int numTest...
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
# -*- coding:utf-8 -*- """ created by shuangquan.huang at 2020/7/1 """ import collections import time import os import sys import bisect import heapq from typing import List def solve(n, l, r): # 1, 2, 1, 3, ..., 1, n # 2, 3, 2, 4, ..., 2, n # ... # n-1, n # 1 lo, hi = 1, 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
java
import java.util.Arrays; 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[...
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.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
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("Ofast") using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, pstart, pend; int t; cin >> t; for (int testcases = 1; testcases <= t; testcases++) { cin >> n >> pstart >> pend; bool completestart = true; b...
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 int N = 3 * 1e5 + 5; const long long MOD = 1000000007; const long long inf = 1e18; using namespace std; long long power(long long x, long long y, long long p) { long long res = 1; x = x % p; if (x == 0) return 0; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 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 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...
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
'''input 3 2 1 3 3 3 6 99995 9998900031 9998900031 ''' import sys import math from collections import Counter debug = 1 readln = sys.stdin.readline #sys.setrecursionlimit(1000000) def write(s): sys.stdout.write(str(s)) def writeln(s): sys.stdout.write(str(s)) sys.stdout.write('\n') def readint(): 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
import java.io.*; import java.util.*; /** * @author Tran Anh Tai * @link: https://codeforces.com/contest/1334/problem/D * @Idea: the minimum lexicographical cycle will be in formed: * 1. (1-2)-(1-3)-(1-4)....-(1-n); (2 * (n - 1)) * 2. (2-3)-(2-4)-(2-5)....-(2-n); (2 * (n - 2)) * 3. ...........................; 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
t=int(input()) for _ in range(t): n,l,r=map(int, input().split()) cycle_size = 2 * (n - 1) cycle_start = 1 cycle_number = 1 # while True: # if cycle_start + cycle_size >= l: # break # cycle_start += cycle_size # cycle_number += 1 # cycle_size -= 2 # pr...
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())): numbers, LEFTs, RIGHTs = map(int, input().split()) KEYSs = 0 GREATS = 0 for i in range(1, numbers+1): if KEYSs + 2 * (numbers-i) >= LEFTs: GREATS = LEFTs-KEYSs-1 break KEYSs += 2 * (numbers-i) LISTs = [] while len(LISTs) < (RIGHTs-LEFTs+1) + GREATS: for j in range(i+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> #pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") using namespace std; long long binpow(long long base, long long exp, int mod) { long long res = 1; while (exp > 0) { if (ex...
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())): n,a,b=map(int,input().split()) if n==2: l=[1,2,1] print (*l[a-1:b]) continue k=n prev=0 for j in range(a,b+1): i=j-prev while k>1: if i<=2*(k-1): if i%2: print (n-k+1,end=" ") else: print (i//2+(n-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
python3
import sys input = sys.stdin.buffer.readline from bisect import bisect_left Q = int(input()) Query = [list(map(int, input().split())) for _ in range(Q)] B = [0] for i in range(1, 2*10**5): B.append(i*(i+1)//2) def solve(n, N): M = N*(N-1) n %= M if n%2 == 0: rem = (M - n)//2 ind = bi...
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; while (t--) { long long n, l, r; cin >> n >> l >> r; vector<long long> pre(n + 1); for (int i = 1; i <= n; i++) { pre[i] = pre[i - 1] + 2 * (n - i); } pre[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
java
import java.util.*; import java.io.*; public class Solution implements Runnable{ FastScanner sc; PrintWriter pw; final class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { ...
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() { int t; cin >> t; while (t--) { long long n, l, r; cin >> n >> l >> r; long long s = 0; long long i; for (i = 1; i <= n - 1; i++) { s += 2 * (n - i); if (l <= s) { s = s - 2 * (n - 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
java
import java.util.Scanner; public class ProblemD { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int t = s.nextInt(); for(int a=0;a<t;a++) { int n = s.nextInt(); long l = s.nextLong(); long r = s.nextLong(); long[] arr = 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; void solve() { long long n, l, r; cin >> n >> l >> r; if (l == n * (n - 1LL) + 1LL) { cout << 1 << '\n'; return; } long long suma = 0LL; long long trenutni = (long long)n - 1LL; while (trenutni > 0) { if (suma + 2 * trenutni >= l) break; suma +...
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 = 1000000007, N = 1e5 + 5, M = 1e5 + 5, INF = 0x3f3f3f3f; long long powmod(long long a, long long b) { long long res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1) res = res * a % mod; a = a * a % mod; } return res; } ...
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 maxc = 1e5; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { long long k = 0; long long n, l, r; cin >> n >> l >> r; for (long long i = 2 * (n - 1); i; k += i, i -= 2) { for (long long j =...
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 math import sys # input = sys.stdin.readline T=int(input()) for _ in range(T): n,l,r=map(int,input().split()) size=r-l+1 run=0 ans=[] for i in range(1,n): run+=2*(n-i) # print(run) if l<=run: prev=run-2*(n-i) gone=l-prev-1 size+=gone # print(gone) cur=0 now=i nex=i+1 flag=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
python3
from sys import stdin, stdout import math def expandList(i,n): if i!=n: out = [] for j in range(n-i): out.append(i) out.append(i+j+1) return out else: return [1] T = int(stdin.readline().rstrip()) for iTest in range(T): n,l,r = list(map(int,stdin.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_LINES = sys.stdin.read().splitlines() # input = iter(_INPUT_LINES).__next__ def go(): # n=int(input()) n,l,r = map(int, input().split()) # a = sorted(map(int, input().split()),reverse=True) tot = n*(n-1)+1 add=[] if r==tot: add=['1'] r-=1 res=[] ...
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 def data(): return sys.stdin.buffer.readline().strip() out=sys.stdout.write def mdata(): return map(int, data().split()) for t in range(int(data())): n,l,r=mdata() a=l for i in range(1,n+1): if 2*(n-i)<=a: a-=2*(n-i) else: break cnt=l ans=[] 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
T = int(input().strip()) for t in range(T): n, l, r = map(int, input().strip().split()) if l == n*(n-1)+1: print(1) continue k = int((2*n-1-((2*n-1)**2-4*l)**0.5)/2) if l <= 2*k*n- k*(k+1): k -= 1 if l > 2*(k+1)*n - (k+1)*(k+2): k += 1 m = 2*k*n - k*(k+1) s = [] k += 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
from sys import * t = int(stdin.readline()) import math for _ in range(t): n,l,r = list(map(int,stdin.readline().split(' '))) if(l == n*n-n+1): print('1') continue k = math.ceil(((2*n-1) - math.sqrt((2*n-1)**2 - 4*l))/2) s = k*(2*n-1 -k) sl = 2*(n-k) lb = k eb = k+1+math...
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; struct R { long long int nd, i; }; int main() { long long int n, l, r, st; scanf("%*d"); while (~scanf("%lld %lld %lld", &n, &l, &r)) { long long int p, i, j, nd; vector<R> v; v.push_back({1, 1}); for (p = 1, i = 2, j = n - 1; i < n; i++, j--) v.push...
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 CodeforcesJava; import java.io.*; import java.util.*; public class Main { public void solve(InputProvider in, PrintWriter out) throws IOException { int testCount = in.nextInt(); for (int test = 0; test < testCount; test++) { long pointCount = in.nextLong(); 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 import collections def read_line(): return sys.stdin.readline()[:-1] def read_int()...