Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const long long int inf = 0x3f3f3f3f3f; const int maxn = 1e5 + 5; int c1[maxn]; int c2[maxn]; int n, m, s, e, v; int main() { cin >> n >> m >> s >> e >> v; for (int i = 1; i <= s; i++) scanf("%d", &c1[i]); for (int i = 1; i <= e; i++) scanf("%d", &c2[i]); int x1, y1...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.*; public class C { static int N, M, ST, EL, V; static TreeSet<Integer> stairs = new TreeSet<Integer>(); static TreeSet<Integer> eles = new TreeSet<Integer>(); static in...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.*; import java.util.*; import java.math.*; import java.util.concurrent.*; public final class ele { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static Random rnd=new...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; long long inf = 1000000000000000000; int main() { long long n, m, a, b, v, q, x1, y1, x2, y2; cin >> n >> m >> a >> b >> v; long long sp[a], ep[b]; for (long long i = 0; i < a; i++) cin >> sp[i]; for (long long i = 0; i < b; i++) cin >> ep[i]; sort(sp, sp + a); ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const long long MAX_INT = 1 << 30; int n, m, cl, ce, q; long long v, l[maxn], e[maxn]; void work() { for (int i = 1; i <= cl; i++) cin >> l[i]; for (int i = 1; i <= ce; i++) cin >> e[i]; cin >> q; l[cl + 1] = e[ce + 1] = MAX_INT; l[0] = ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { long long n, m, cl, ce, v; cin >> n >> m >> cl >> ce >> v; int l[100001]; int e[100001]; for (int i = 0; i < cl; ++i) { cin >> l[i]; } for (int i = 0; i < ce; ++i) { cin >> e[i]; } int q; cin >> q; long ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
from bisect import bisect_left input = __import__('sys').stdin.readline MIS = lambda: map(int,input().split()) def walk(x1, y1, x2, y2, L, v): if y1 == y2: return abs(x2-x1) dy = abs(y1-y2) vertical = dy // v if dy%v: vertical+= 1 i = bisect_left(L, x1) xs1 = L[i-1] if 0<=i-1<len(L) e...
PYTHON3
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import math from bisect import bisect_left from bisect import bisect_right n, m, cl, ce, v = map(int, raw_input().split()) l = map(int, raw_input().split()) e = map(int, raw_input().split()) q = input() for i in range(q): x1, y1, x2, y2 = map(int, raw_input().split()) if x1 == x2: print abs(y2 - y1) ...
PYTHON
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const long long infLL = 9000000000000000000; inline bool checkBit(long long n, int i) { return n & (1LL << i); } inline long long setBit(long long n, int i) { return n | (1LL << i); ; } inl...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; long long xx1, yy1, xx2, yy2; long long n, m, s, e, v, q; long long stair[100005], elev[100005]; long long diff(long long tx1, long long ty1, long long tx2, long long ty2, bool walk) { if (walk) return abs(tx1 - tx2) + abs(ty1 - ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9; const int base = 1e9; const int MAX = 2e5; const long double EPS = 1e-10; const long double PI = acos(-1.); int n, m; int D, E, v; int d[MAX]; int e[MAX]; int x1, x2, adlsdss, y2; int drab() { int cur = INF; int pos = lower_...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n, m, cl, ce, v, q; int lou[100005]; int dian[100005]; int work(int sx, int sy, int ex, int ey) { if (sx == ex) return abs(sy - ey); int k = lower_bound(lou, lou + cl, sy) - lou; int ans = inf; if (k < cl) { int pos = lou[k]; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; int main() { long long int n, m, cl, ce, v, x, y, z, i, j, k, x1, y1, x2, y2, ans, f; cin >> n >> m >> cl >> ce >> v; vector<long long int> s(cl), e(ce); for (i = 0; i < cl; i++) cin >> x, s[i] = x; for (i = 0; i < ce; i++) cin >> x, e[i] = x; long long int q; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
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; /** * @author khokharnikunj8 */ public class Main { public static void main(String[] args) { ...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
from bisect import bisect_left, bisect_right n, m, ncl, nce, v = map(int, raw_input().split()) cs = map(int, raw_input().split()) ce = map(int, raw_input().split()) q = int(raw_input()) ################## def cost(arr, index, y1, y2): if index >= len(arr): index = len(arr) - 1 pos = arr[index] #...
PYTHON
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
def takeClosest(myList, myNumber): """ Assumes myList is sorted. Returns closest value to myNumber. If two numbers are equally close, return the smallest number. """ if len(myList) == 0: return 9e10 pos = bisect_left(myList, myNumber) if pos == 0: return myList[0] if pos...
PYTHON3
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class CF { static class server { int dist; int index; public server(int dist, int index) { this.dist = dist; this...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author dipankar12 */ import java.io.*; import java.util.*; public class r477c { public static void main(String args[])...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int maxn = 1e5 + 50; const int inf = 1e8 + 10; int l[maxn], e[maxn]; int bs(int a[], int x, int n) { int l = 0, r = n; int m; while (l < r) { m = (l + r) / 2; if (a[m] >= x) r = m; else l = m + 1; } return l; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; const int MOD = 1e9 + 7; const int INF = 1e9; const int base = 1e9; const int MAX = 2e5; const long double EPS = 1e-10; const long double PI = acos(-1.); int n, m; int D, E, v; int d[MAX]; int e[MAX]; int x1, x...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; long long a[100100], b[100100]; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long n, m, cl, ce, v, x1, y1, x2, y2, q, mi; cin >> n >> m >> cl >> ce >> v; for (long long i = 0; i < cl; i++) cin >> a[i]; for (long long i = 0; i < ce; i++) cin ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.BufferedOutputStream; public class StairsAndElevators{ static class FastReader { BufferedReader br; StringTokenizer st; p...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; int a[100010], b[100010]; int main() { int n, m, c1, c2, v; scanf("%d%d%d%d%d", &n, &m, &c1, &c2, &v); for (int i = 1; i <= c1; i++) { scanf("%d", &a[i]); } for (int i = 1; i <= c2; i++) { scanf("%d", &b[i]); } int q; a[0] = -2e8, a[c1 + 1] = 2e8; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; long long n, m, cl, ce, v; vector<long long> stairs; vector<long long> elevators; long long closest(std::vector<long long> const& vec, long long value) { auto const it = std::lower_bound(vec.begin(), vec.end(), value); if (it == vec.end()) { return (vec.size() - 1);...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 9; const int INFINT = 1e9 + 9; const long long INFLL = 1e18 + 9; const long double EPS = 1e-12; const char C = 'a'; const long long MOD = 1e9 + 7; const long long BASE = 31; vector<int> E, L; int main() { ios::sync_with_stdio(0); int n, m, cl, ce, v,...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.util.*; public class Test5{ static int lesn, lifts, v; static int[] lesnpos , liftpos; public static void main(String[] z) { Scanner s = new Scanner(System.in); int a = s.nextInt(), b=s.nextInt(), zapr,x1,x2,y1,y2, glif=-1, gles=-1, rles, lles, rlif, llif, f1, f2, f3,f4,f5,f6...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; const int INF = 1e9; int n, m, cl, ce, v, q; int a[maxn + 5], b[maxn + 5]; int main() { scanf("%d%d%d%d%d", &n, &m, &cl, &ce, &v); for (int i = 1; i <= cl; i++) scanf("%d", &b[i]); for (int i = 1; i <= ce; i++) scanf("%d", &a[i]); sort(a + 1, a...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
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.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.Input...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; template <typename T, typename S> ostream &operator<<(ostream &os, const pair<T, S> &v) { os << "("; os << v.first << "," << v.second << ")"; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "["; long long sz = v.size...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.util.*; import java.io.*; public class Source { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); ...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; int bins(const vector<long long>& vec, long long x) { int low = -1; int high = (int)vec.size() - 1; while (low != high) { int mid = (low + high + 1) >> 1; if (vec[mid] <= x) low = mid; else high = mid - 1; } retu...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.util.*; import java.io.*; import java.lang.*; import java.math.*; import static java.lang.Math.*; import java.util.concurrent.ThreadLocalRandom; public class Sol implements Runnable { long mod = (long)1e9 + 7; void solve(InputReader in, PrintWriter w) { long n = in.nextLong(), m = in.next...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import sys import math import bisect def closests(l,y): idx = bisect.bisect_left(l, y) if idx == 0: return l[0], -1 if idx == len(l): return l[-1], -1 return l[idx], l[idx - 1] n, m, cl, ce, v = map(int, sys.stdin.readline().strip().split(' ')) if cl > 0: stairs = list(map(int, sys.st...
PYTHON
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; long long int ans = 1e9 + 7, ww = 0, x1, y3, x2, y2; long long int l[100007], e[100007]; inline void check(long long int x) { long long int mx = ww; if (e[x] <= x1) mx += (x1 - e[x]) * 2; if (e[x] >= x2) mx += (e[x] - x2) * 2; mx += x2 - x1; if (mx < ans) ans = mx...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const long long INF = 1e18; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long n, m, cl, ce, v; cin >> n >> m >> cl >> ce >> v; vector<long long> data_l(cl), data_e(ce); for (long long i = 0; i < cl; i++) { long long k; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; long long N, M, S, E, V, Q; long long s[100005]; long long e[100005]; long long binariaelevador(long long x1, long long y1, long long x2, long long y2) { if (!E) return 1e18; long long ini = 1, fin = E; while (ini < fin) { long long mid =...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.io.Reader; import java.io.StreamTokenizer; import java.math.BigInteger; import java.util.*; import static java.lang.Math.max; import static java.lang.Math.min;...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; //import javax.print.attribute.IntegerSyntax; public class test{ public static void swap(int a,int b){ int c = a; a = b; b = c; } public static void main(String[] args) throws IOExceptio...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, cl, ce, v, q, x1, yy1, x2, y2, tt; set<int> l, e; long long p, pp, p1, pp1, lp; set<int>::iterator tl, te, tl1, te1; void JZZ() { printf("--- %d %d %d %d %d %d %d %d %d\n", p, p1, pp, pp1, *te, *te1, *tl, *tl1, tt); } int main() { cin >> n >> m >> cl ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeSet; import static java.lang.Math.*; public class C implements Closeable { private...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; long long n, m, l, s, vl[100002], vs[100002], spl; long long q, xa, ya, xb, yb; long long bls(long long nr) { if (nr < vl[1]) return -1; int b = 1; int e = l; long long sol = -1; while (b <= e) { int mid = (b + e) / 2; if (vl[mid...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; using LL = int64_t; const int maxn = 1e5 + 5; const int mod = 1e9 + 7; const int INF = 0x3f3f3f3f; const LL LLINF = 1e14; const double pi = acos(-1.0); vector<int> c, l; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, cl, cc, v; cin >> n >> m >> cl >> cc...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.*; import java.util.*; public class StairsAndElevators { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader inp = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStrea...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; int n, m, cl, ce, v, q; int lou[100005]; int dian[100005]; int work(int sx, int sy, int ex, int ey) { if (sx == ex) return abs(sy - ey); int k = upper_bound(lou, lou + cl, sy) - lou; int ans = inf; if (k < cl) { int pos = lou[k]; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5, inf = 200000000; int n, m, sn, en, v, s[N], e[N], ns[N], ne[N]; inline __attribute__((always_inline)) int readin() { char c = getchar(); bool neg = (c == '-'); while (!('0' <= c && c <= '9')) c = getchar(), neg |= (c == '-'); int t = 0; for ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const double EPS = 1e-9; const int INF = 0x7f7f7f7f; const double PI = acos(-1.0); char CRTBUFF[30000]; template <class T> inline T gcd(T a, T b) { return (b) == 0 ? (a) : gcd((b), ((a) % (b))); } template <class T> inline T lcm(T a, T b) { return ((a) / gcd((a), (b)) *...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> void solve(const int n, const int m, const int cl, const int ce, const int v, const int *ll, const int *e) { int x, y, p, q; scanf("%d%d%d%d", &x, &y, &p, &q); if (x == p) { printf("%d\n", ((y - q) > (0) ? (y - q) : -(y - q))); return; } if (y > q) { int swap = ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.TreeSet; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author p...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 10; const long long mod = 1e9 + 7; const int INF = 1e9; const double eps = 1e-6; int n, m; int a[maxn]; int b[maxn]; char s[maxn]; int main() { int an, bn, v; scanf("%d%d%d%d%d", &n, &m, &an, &bn, &v); for (int i = 0; i < an; i++) scanf("%d", &a...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.*; import java.util.*; /** * * @author akashvermaofskt * Coding is love <3! */ public class C { public static void main(String args[]) { try { long n=nextLong(); long m=nextLong(); int cl=nextInt(); int ce=nextInt(); long v...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * @author Don Li */ public class StairsAndElevators { int INF = (int) 1e9; int n, m, num_stairs, num_elevators, v; int[] stairs, elevato...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
// practice with kaiboy import java.io.*; import java.util.*; public class CF967C extends PrintWriter { CF967C() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF967C o = new CF967C(); o.main(); o.flush(); } int search(int[] aa, int n, int a) { int lower = -...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; int a[100010], b[100010]; int main() { int n, m, c1, c2, v; scanf("%d%d%d%d%d", &n, &m, &c1, &c2, &v); for (int i = 1; i <= c1; i++) { scanf("%d", &a[i]); } for (int i = 1; i <= c2; i++) { scanf("%d", &b[i]); } int q; a[0] = -2e9, a[c1 + 1] = 2e9; ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.io.BufferedReader; // import java.io.FileInputStream; // import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.*; import static java.util.Arrays.fill; import static java.util.Arrays.sort; impor...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.util.Arrays; import java.util.Scanner; /** * Created by makarfi on 4/29/18. */ public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(), m = in.nextInt(), numStairs = in.nextInt(), numElevators = in.nextInt()...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
import java.util.*; import java.io.*; public class StairsElevators { /************************ SOLUTION STARTS HERE ************************/ static TreeSet<Long> stairs, elevs; static final long INF = (long) 1e15; static long checkPossibility(long speed, long x1, long y1, ...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; const double esp = 1e-12; const int ff = 0x3f3f3f3f; map<int, int>::iterator it; long long n, m, c1, c2, vv; long long sx, sy, ex, ey; long long s[maxn], v[maxn]; long long get_r(long long x, long long a[], int o) { long long l = 1, r = c1; if ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
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...
JAVA
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, cs, ce, v, s[100005], e[100005], q, a, b, c, d, p, w, ans; int main() { scanf("%d%d%d%d%d", &n, &m, &cs, &ce, &v); for (int i = 1; i <= cs; i++) scanf("%d", &s[i]); for (int i = 1; i <= ce; i++) scanf("%d", &e[i]); scanf("%d", &q); while (q--) { ans ...
CPP
967_C. Stairs and Elevators
In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on different floors are l...
2
9
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; int n, m, cl, ce, v, Q, L, R, D, U, p, best; int l[maxn], e[maxn]; void updateL(int p) { if (p < 1 || cl < p) return; int need = U - D; need += abs(l[p] - L) + abs(l[p] - R); best = min(best, need); } void updateE(int p) { if (p < 1 || ce ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int a[100]; int b[100]; map<int, int> mp; int k = 0; set<int> sl[20010], sr[20010], sll, srr; set<int>::iterator it; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= m; ++i) cin >> b[...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); int n, m, p; cin >> n >> m; vector<int> V(n), W(m); for (int i = 0; i < n; ++i) cin >> V[i]; for (int i = 0; i < m; ++i) cin >> W[i]; set<int> all; for (int x : V) for (int y : W) all.i...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, a[66], b[66]; bitset<200> bt[6666]; map<double, int> mp; int ind = 0; int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int j = 1; j <= m; j++) { cin >> b[j]; } for (int i = 1; i <= n;...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
import java.io.*; import java.util.*; public class A { FastScanner in; PrintWriter out; class O implements Comparable<O> { int i; int j, sum; public O(int i, int j, int sum) { this.i = i; this.j = j; this.sum = sum; } @Override ...
JAVA
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 100; const int MAXM = 10005; int n, m, ans, a[2][MAXN], flag[2][MAXM * 10 + 5], sig[MAXM * 10], num[MAXM], cnt, add[2][MAXN][MAXM]; bitset<64> f[MAXM * 10], g[MAXM * 10], ff, gg; void solve1(int i, int p) { int q = p ^ 1; ; int x = a[p][i]; int ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; int a[66], b[66]; vector<int> g[2][20002]; vector<pair<long long, long long> > v; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] += 10000; g[0][a[i]].push_back(i);...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int nmax = 100 * 2; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; map<int, bitset<nmax> > mapa; vector<int> a(n), b(m); for (int i = 0; i < n; ++i) { cin >> a[i]; } for (int j = 0; j < m; ++j) ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; const long long inf64 = 1e18; const int X = 1e4 + 5; const int N = 65; bitset<2 * N> bs[N][N]; int n, m; int a[N]; int b[N]; vector<int> pa[2 * X], pb[2 * X]; int main() { cin >> n >> m; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] += X; ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; map<int, int> le_, ri_; vector<pair<int, int> > le, ri; map<int, int> cur; vector<char> u1, u2; int main() { scanf("%d%d", &n, &m); for (int i = 0, x; i < n; ++i) scanf("%d", &x), ++le_[2 * x]; for (int i = 0, x; i < m; ++i) scanf("%d", &x), ++ri_[2 * x]; ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; namespace variables { struct triple { long long first, second, third; }; } // namespace variables using namespace variables; void testt(); namespace andu2006 { void debug(set<long long> _var, string _name = "") { cerr << "Debug #set " << _name << " = ["; for (auto it...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") using namespace std; const long double eps = 1e-10; struct Point { long double first, second; Point() : first(0), second(0) {} Point(long double _x, long double _y) : first(_x), second(_y) {} Po...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m; const int M = 20000; bool ciekawe[4 * M + 7]; const int N = 60; pair<int, int> ya[N + 7]; pair<int, int> yb[N + 7]; int wynik = 0; bool znia[N + 7]; bool znib[N + 7]; int pom[4 * M + 7]; int dopchnij() { int res = 0; for (int i = 0; i < n; ++i) { for (int ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, i, j, k, z, m, q, h, r, timer, mx, l, cnt, u, v, t, s, tot; int a[105], b[105]; bitset<121> dp[100500]; bitset<121> magic; vector<int> f; int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; for (int i ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; using bs = bitset<100>; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n), b(m); for (int i = 0; i < n; ++i) { cin >> a[i]; a[i] *= 2; } for (int i = 0; i < m; ++i) { cin >> b[i]; b[i] *= 2; ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.io.IOException; import java.io.UncheckedIOException; import java.io.Closeable; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.InputStream; /**...
JAVA
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, x[66], y[66], ta, ans; map<int, bitset<120> > mm; map<int, bitset<120> >::iterator it, itt; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", x + i); for (int i = 0; i < m; i++) scanf("%d", y + i); for (int i = 0; i < n; i++) ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const long long INF = 1000000000; const int MAX_N = 65; const int D = 100000; int a[MAX_N]; int b[MAX_N]; set<int> s; int y[MAX_N * MAX_N]; bitset<MAX_N> tmpa; bitset<MAX_N> tmpb; int bs[300000]; int as[300000]; int main() { int n, m; cin >> n >> m; for (int i = 0; i ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; int a[n]; int b[m]; for (int i = 0; i < n; i++) { cin >> a[i]; a[i] *= 2; } for (int i = 0; i < m; i++) { cin >> b[i]; b[i] *= 2; } vector<pair<int, int...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Div1_488C { static int nA; static int nB; public static...
JAVA
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const long long int mod = 1e9 + 7; const long long int inf = 1e9; const long long int N = 65; const long long int NN = 500005; long long int x[N], y[N], n, m; long long int xx[NN], yy[NN]; long long int val[NN]; vector<long long int> xx1, yy1; long long int f(long long int ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, cnt, ans, q[40010], tot, x[40010], y[40010], fv[40010], id[40010], cnt1, c[40010]; bool p[40010]; vector<int> d[40010]; void add(int k) { ans += ((++c[k]) == 1); } void del(int k) { ans -= ((c[k]--) == 1); } int main() { int i, s, a, b, j, k; scanf("%d%d",...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; long long n, m, yes, i, j, k, t, x, y, l, r, tmp, cnt, curr, ans; long long arr[1000005], brr[1000005], flg[1000005]; vector<pair<long long, long long> > v, u; map<long long, vector<long long> > mp; map<long long, long long> mpp[1000005]; int main() { ios_base::sync_with_...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 128; int N, M; int L[MAXN], R[MAXN]; int main() { cin.tie(0); cin.sync_with_stdio(0); cin >> N >> M; for (int a = 0; a < N; a++) { cin >> L[a]; } for (int a = 0; a < M; a++) { cin >> R[a]; } map<long long, bitset<MAXN>> mids; for (...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.writ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> template <typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; } template <typename First, typename... Rest> void MACRO_VAR_Scan(First& first, Rest&... rest) { std::cin >> first; MACRO_VAR_Scan(rest...); } template <typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); } tem...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const string yno[2] = {"NO\n", "YES\n"}; int dem(vector<int> &a, int k) { return upper_bound(a.begin(), a.end(), k) - lower_bound(a.begin(), a.end(), k); } int dem(long long k) { int ans = 0; while (k) { ans += k & 1; k >>= 1; } return ans; } void...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; long long n, m; map<double, long long> mpa; map<double, long long> mpb; vector<pair<long long, long long> > A; vector<pair<long long, long long> > B; vector<long long> a, b; vector<pair<double, pair<long long, long long> > > v; int main() { ios_base::sync_with_stdio(false...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 100; map<int, bitset<125> > lnk; int a[N], b[N], n, m; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", &a[i]); for (int i = 0; i < m; i++) scanf("%d", &b[i]); lnk.clear(); for (int i = 0; i < n; i++) for (int j = 0; j ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; inline long long read() { char ch = getchar(); long long nega = 1; while (!isdigit(ch)) { if (ch == '-') nega = -1; ch = getchar(); } long long ans = 0; while (isdigit(ch)) { ans = ans * 10 + ch - 48; ch = getchar(); } if (nega == -1) return ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int MAXN = 65; template <typename T> void chkmax(T& x, T y) { if (y > x) x = y; } template <typename T> void chkmin(T& x, T y) { if (y < x) x = y; } int N, M, a1[MAXN], a2[MAXN], c1[MAXN], c2[MAXN]; bool d1[MAXN], d2[MAXN]; int buc[40005], ans; int b1[20005], b2[2...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; map<int, int> mp; int p1[110], p2[110]; long long lset[4000], rset[4000]; int compute(long long now); int main() { int n, m, k = 0, ans = 0; scanf("%d%d", &n, &m); for (int i = 1; i <= n; i++) scanf("%d", &p1[i]); for (int i = 1; i <= m; i++) scanf("%d", &p2[i]); ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, val, l1[80400], l2[80400]; vector<int> v1, v2, pos; int main() { ios::sync_with_stdio(0); cin >> n >> m; for (int i = (0); i <= ((int)(n)-1); i++) { cin >> val; v1.push_back(val); l1[val + 40200] = 1; } for (int i = (0); i <= ((int)(m)-1); i+...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; bool exist(int x, multiset<pair<int, int>>& s, bool in_first) { for (multiset<pair<int, int>>::iterator it = s.begin(); it != s.end(); ++it) if ((in_first && it->first == x) || (!in_first && it->second == x)) return true; return false; } int num_uniq(multiset<...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int a[100]; int b[100]; map<int, int> cnt; int k = 0; set<int> ls[20010], rs[20010], x, y; set<int>::iterator it; int main() { ios::sync_with_stdio(false); int n, m; cin >> n >> m; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= m; ++i) cin >> b[i];...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; using LL = long long; int z1[61], z2[61]; bool v1[61], v2[61]; int q1[40010], q2[40010]; int *cnt1 = q1 + 20001, *cnt2 = q2 + 20001; bool vv1[40010], vv2[40010]; bool *vp1 = vv1 + 20001, *vp2 = vv2 + 20001; LL temp1[40010], temp2[40010]; LL *destroy1 = temp1 + 20001, *destr...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 4e4 + 10; const int A = 2e4; int a[66], b[66]; bitset<61> dl[N], dr[N]; int main() { int n, m; cin >> n >> m; vector<int> v; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; for (int i = 0; i < n; i++) { for (in...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; int n, m, ay[66], by[66]; set<int> aux[100010]; bool app[100010]; int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", &ay[i]); for (int i = 0; i < m; i++) scanf("%d", &by[i]); vector<int> used; for (int i = 0; i < n; i++) for (int j = ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; unsigned int popcount64(unsigned long long x) { x = (x & 0x5555555555555555ULL) + ((x >> 1) & 0x5555555555555555ULL); x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL); x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL); return (...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10, mod = 1e9 + 7; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; int a[n], b[m]; map<int, long long> mp[2]; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin ...
CPP
993_C. Careful Maneuvering
There are two small spaceship, surrounded by two groups of enemy larger spaceships. The space is a two-dimensional plane, and one group of the enemy spaceships is positioned in such a way that they all have integer y-coordinates, and their x-coordinate is equal to -100, while the second group is positioned in such a wa...
2
9
#include <bits/stdc++.h> using namespace std; long long inc1[20000 * 3], inc2[20000 * 3], st1[64 * 64], st2[64 * 64]; int n, m, t1, t2, x1[64], x2[64], t, ans, cnt[1 << 20]; inline int count(long long x) { return cnt[x & (1048576 - 1)] + cnt[(x >> 20) & (1048576 - 1)] + cnt[x >> 40]; } int main() { for (int i = 0; ...
CPP