prompt
string
response
string
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) a, b = 0, 0 for i in range(2*n): c, d = [int(x) for x in input().split()] a += c b += d print(a // n, b // n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); int arr[n + 5][3]; for (int i = 1; i <= n; i++) scanf("%d %d", &arr[i][1], &arr[i][2]); map<pair<int, int>, int> mp; int clue[n + 5][3]; for (int i = 1; i <= n; i++) { scanf("%d %d", &clue[i][1], &clue[i][2]); mp[ma...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.*; import java.io.*; public class node2 { public static void main(String[] args)throws IOException { Scanner sc=new Scanner(System.in); //Scanner sc=new Scanner(new File("ip.txt")); int n,i; n=sc.nextInt(); int cx[][]=new int[n][2]; //int cy[]=new int[n]; int vx[][]=new int[n][2]; ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.*; import java.util.*; import java.math.*; public class Practice implements Comparator<Long> { public int compare(Long x,Long y) { if(x>y) return -1; else if(y>x) return 1; return 0; } public static void main(String[] args)throws Exception{ Scanner sc=new Scanner(System.in); ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
def fastio(): import sys from io import StringIO from atexit import register global input sys.stdin = StringIO(sys.stdin.read()) input = lambda : sys.stdin.readline().rstrip('\r\n') sys.stdout = StringIO() register(lambda : sys.__stdout__.write(sys.stdout.getvalue())) fastio() MOD = 10...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long sumx = 0; long long sumy = 0; for (long long i = 0; i < n; i++) { long long a, b; cin >> a >> b; sumx += a; sumy += b; } for (long long i = 0; i ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n=int(input()) A=0 B=0 for i in range(2*n): a,b=map(int,input().split(' ')) A+=a B+=b print(A//n,B//n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int n; pair<int, int> a[1010], b[1010]; map<pair<int, int>, int> cnt; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].first >> a[i].second; } for (int i = 1; i <= n; i++) { cin >>...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.*; import java.util.*; public class code1091B { static class Par implements Comparable<Par>{ int x,y; public Par(int a,int b){ x=a; y=b; } public int compareTo(Par p){ int res=x-p.x; if(res==0){ res=y-p.y; } return res; } } public static void main(String[] a...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long sumx = 0, sumy = 0; for (int i = 0; i < 2 * n; i++) { int x, y; cin >> x >> y; sumx += x; sumy += y; } cout << sumx / n << " " << sumy / n; }
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const long long N = 5e5; const long long INF = 1e17 + 10; const long long mod = 998244353; long long n, m, i, j, l, r, x, y, k, now; pair<long long, long long> a[N], b[N]; int main() { cin >> n; for (i = 0; i < n; ++i) { cin >> x >> y; a[i] = {x, y}; } for (...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main(void) { int loc_x = -1000001; int loc_y = -1000001; int clue_x = 2000001; int clue_y = 2000001; int n; cin >> n; for (int i = 0; i < n; i++) { int ai, bi; cin >> ai >> bi; if (loc_x < ai) { loc_x = ai; } if (loc_y < bi) { ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) obs= [] ops = [] locs = {} for _ in range(n): obs.append(list(map(int, input().split()))) for _ in range(n): x, y = map(int, input().split()) for o in obs: nloc = (o[0]+x, o[1]+y) if nloc not in locs: locs[nloc] = [] locs[nloc].append(o) for l in locs: if len(locs[l]) == n: print(l[0], l...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.*; public class GoodBye2018ProblemB { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); List<List<Integer>> l = new ArrayList<>(); List<List<Integer>> l2 = new ArrayList<>(); int n = scanner.nextInt(); scanner.nextLine()...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); long x=0,y=0; for(int i=1;i<=n*2;i++) { int x0=sc.nextInt(); int y0=sc.nextInt(); x+=x0; y+=y0; } x/=n; y/=n; System.out.println(x + " " + y); ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; pair<int, int> c[n]; pair<int, int> d[n]; pair<int, int> minc; pair<int, int> maxd; for (int i = 0; i < n; ++i) { cin >> c[i].first >> c[i].second; if (i == 0) { minc = c[i]; } else { if (c[i].first == minc...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; struct node { int x, y; void scan() { scanf("%d%d", &x, &y); } bool operator<(const node p) const { return x == p.x ? y < p.y : x < p.x; } bool operator==(const node p) const { return (x == p.x) && (y == p.y); } node operator+(node p) { ret...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; template <typename integer> integer __lcm(integer a, integer b) { return (a * b) / __gcd(a, b); } int main() { int n; cin >> n; vector<int> xs(n), ys(n), as(n), bs(n); map<pair<int, int>, int> m; for (int i = 0; i < (int)(n); i++) cin >> xs[i] >> ys[i]; for (i...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) x = 0 y = 0 for i in range(2 * n): a, b = map(int, input().split()) x += a y += b print(x // n, y // n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; template <typename I> inline void read(I& x) { int f = 0, c; while (!isdigit(c = getchar())) c == '-' ? f = 1 : 0; x = c & 15; while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15); f ? x = -x : 0; } template <typename A, typename B> inline char SMAX(A...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const int maxn = 1010; int n, x[maxn], y[maxn], a[maxn], b[maxn], tong1[maxn], tong2[maxn], ansx, ansy; map<pair<int, int>, int> M; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]); for (int i = 1; i <= n; i++) scanf("%d%d", &a[i]...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.*; import java.util.*; import java.util.Map.Entry; import javax.swing.text.InternationalFormatter; import java.math.*; public class temp1 { public static PrintWriter out; static int[] a; static int[] b; static int[][][][] dp; static ArrayList<pair> p = new ArrayList<>(); static int ans = 0; ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.Scanner; public class Codechef { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n = sc.nextInt(); long x =0; long y=0; for(int i=0;i<2*n;i++) { x=x+ sc.nextInt(); y=y+ sc.nextInt(); ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
def mi(): return map(int, input().split()) ''' 2 2 5 -6 4 7 -2 -1 -3 ''' n = int(input()) c = [0]*n for i in range(n): c[i] = list(mi()) d = [0]*n for i in range(n): d[i] = list(mi()) possans = [0]*(n*n) k = 0 for i in range(n): for j in range(n): t1 = (c[i][0]+d[j][0],c[i][1]+d[j][1]) p...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int n; vector<pair<int, int> > a, b; int main() { cin >> n; for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; a.push_back(pair<int, int>(x, y)); } for (int i = 1; i <= n; i++) { int x, y; cin >> x >> y; b.push_back(pair<int, int>(x, y))...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.Scanner; public class Main { static int[] obelX; static int[] obelY; static int[] clueX; static int[] clueY; public static void main(String[] args) { Scanner s =new Scanner(System.in); int n = s.nextInt(); obelX = new int[n]; obelY = new int[n]; ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.BitSet; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Map; import java.util.Optional; import java.u...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.*; import java.util.*; import java.lang.*; import java.math.*; public class E { public void run() throws Exception { FastScanner sc = new FastScanner(); int n = sc.nextInt(); long x = 0; long y = 0; for (int i = 0; i<2*n; i++) { long a = sc.nextLong(); long b = sc.nextLong(); x+=...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
x, y = 0, 0 n = int(input()) for _ in range(2*n): a, b = map(int, input().strip().split()) x += a y += b print(x // n, y // n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(raw_input()) obelisk = set() for i in xrange(n): obelisk.add(tuple(map(int, raw_input().split()))) hints = [] for i in xrange(n): hints.append(map(int, raw_input().split())) x, y = hints[0] candidates = [(x + a, y + b) for a, b in obelisk] looked_obelisks = {o: False for o in obelisk} for c in can...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.FilterInputStream; import java.io.BufferedInputStream; import java.io.InputStream; /** * @author khokharnikunj8 */ public class Main { public static void main(...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) x = y = 0 for _ in range(2 * n): dx, dy = map(int, input().split()) x += dx y += dy print(x // n, y // n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
from operator import * n = input() x, y = map(sum, map(concat, *[zip(*[map(int, raw_input().split()) for _ in range(n)]) for _ in range(2)])) print x/n, y/n
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const int N = 2000; struct node { int x, y; } a[N], b[N]; bool cmp(node xx, node yy) { if (xx.x != yy.x) { return xx.x < yy.x; } else return xx.y < yy.y; } int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i].x >> a[i].y; } fo...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) x=y=dx=dy=0 for _ in range(n): a, b = map(int, input().split()) x, y = x+a, y+b for _ in range(n): a, b = map(int, input().split()) dx, dy = dx+a, dy+b print((x+dx)//n, (y+dy)//n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; struct tt { int x, y; }; tt a[1010], b[1010]; int p[1010], vis[1010]; bool cmp(tt a, tt b) { if (a.x == b.x) return a.y < b.y; return a.x < b.x; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d%d", &a[i].x, &a[i].y); } for ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.*; public class New1 { public static void main(String args[]) { Scanner s1=new Scanner(System.in); int n=s1.nextInt(); long sumx=0; long sumy=0; for(int i=0;i<2*n;i++) { sumx+=s1.nextLong(); sumy+=s1.nextLong(); ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.*; import java.util.*; public class Makise { static PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws Exception{ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x[]=new int[n]; int y[]=new int[n]; int a[]=new int [n]; int b[]=new int[n];...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import sys import math def main(): n = int(input()) obelisk = [tuple(map(int, input().split())) for _ in range(n)] clue = [tuple(map(int, input().split())) for _ in range(n)] for i in range(n): x, y = obelisk[i][0] + clue[0][0], obelisk[i][1] + clue[0][1] lol = [(x - ox, y - oy) f...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.stream.IntStream; import java.util.Arrays; import java.util.stream.LongStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.OptionalInt; import java.io.Unch...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n; cin >> n; int x[n], y[n], a[n], b[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int tx, ty; for (int i = 0; i < n; ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import static java.lang.Math.*; import java.io.*; import java.util.*; public class ProblemB { final static long mod = 1_000_000_007l; final static int maxn = 1_000_007; final static long infty = 1_000_000_009l; // final static boolean DEBUG = true; final static boolean DEBUG = false; // solve...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) p = [] q = [] for _ in range(n): r = tuple(map(int, input().split(' '))) p.append(r) for _ in range(n): r = tuple(map(int, input().split(' '))) q.append(r) p = sorted(p) q = sorted(q) x, y = p[0][0] + q[0][0], p[0][1] + q[0][1] alt = False for i in range(n): if p[i][0] ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a % b) : a); } template <class T> T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); } template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while (~c && c < '0' || c > '9') { ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) s1 = 0 s2 = 0 for i in range(n): k, l = map(int, input().split()) s1 += k s2 += l for i in range(n): k, l = map(int, input().split()) s1 += k s2 += l print(s1 // n, s2 // n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) obs = [] clues = [] for i in range(n): x,y = map(int, input().split()) obs.append([x,y]) for i in range(n): x,y = map(int, input().split()) clues.append([x,y]) obs = sorted(obs, key = lambda x:x[0]+x[1]+x[1]) clues = sorted(clues, key = lambda x:x[0]+x[1]+x[1], reverse = True) print(obs...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { long long int a[1001][3], b[1002][3], n, i, j, s1, s2, x, y, l = 1, h = 0, sum1 = 0, sum2 = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> a[i][1] >> a[i][2]; sum1 = sum1 + a[i][1]; sum2 = sum2 + a[i][2]; } for (i = 1; i <= n; i++) {...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; long long n; pair<long long, long long> verify; bitset<1001> veri; map<pair<long long, long long>, long long> ver; vector<pair<long long, long long> > ob; bool search() { bool bad = true; pair<long long, long long> temp; for (long long t = 1; t < n; t++) { temp.fi...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; class Point { public: int x, y; Point(int a, int b) { x = a; y = b; } Point() {} }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, tempx, tempy; cin >> n; Point **ob, **cl; ob = new Point *[n]; cl = new Point *[n]; for ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const long long mx = 100001; const long long mod = 1000000007; const long long inf = 0x3f3f3f3f; void solve(); int main() { int t = 1; for (int i = 1; i <= t; i++) { solve(); if (i != t) printf("\n"); } return 0; } int X[1001], Y[1001], x[10001], y[10001]; v...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { int n, Tx, Ty; cin >> n; pair<int, int> xy[n], ab[n]; for (int i = 0; i < n; i++) { cin >> xy[i].first >> xy[i].second; } for (int i = 0; i < n; i++) { cin >> ab[i].first >> ab[i].second; } cout << max_element(xy, xy + n)->first + min_el...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) a = [tuple(map(int, input().split())) for i in range(n)] b = [tuple(map(int, input().split())) for i in range(n)] x = min(a) h = max(b) print(x[0] + h[0], x[1] + h[1])
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
/** * Created by Baelish on 12/30/2018. */ import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class B { public static void main(String[] args) throws Exception { FastReader in = new FastReader(Syste...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n=int(input()) t1=0 t2=0 for i in range(0,n): x,y=map(int,input().split()) t1+=x t2+=y for i in range(0,n): a,b=map(int,input().split()) t1+=a t2+=b print(t1//n,t2//n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3 + 5; const int mod = 998244353; map<pair<int, int>, int> mp; pair<int, int> a[maxn], b[maxn]; int n; int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d%d", &a[i].first, &a[i].second); for (int i = 1; i <= n; ++i) scanf("%d%d", &b...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; long long int x[n], y[n], a[n], b[n]; long long int alpha = 0; long long int beta = 0; for (long long int i = 0; i < n; i++) { cin >> x[i] >> y[i]; alpha += x[i]...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
first_coordinates = [] N = int(input()) for i in range(N): x, y = map(int, input().split()) first_coordinates.append((x, y)) second_coordinates = [] for j in range(N): x, y = map(int, input().split()) second_coordinates.append((x, y)) first_coordinates.sort(key=lambda x: x[1]) first_coordinates.sort(key...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = input() x, y = map(sum, zip(*[map(int, raw_input().split()) for _ in range(2*n)])) print x/n, y/n
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int n; long long ans1, ans2; int main() { scanf("%d", &n); for (int i = 1; i <= 2 * n; i++) { int x, y; scanf("%d%d", &x, &y); ans1 += x; ans2 += y; } printf("%lld %lld\n", ans1 / n, ans2 / n); }
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const int N = 1005; pair<int, int> a[N], b[N], s[N][N]; map<pair<int, int>, int> cnt; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; for (int i = 1; i <= n; i++) ci...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) x, y = 0, 0 for _ in range(2*n): a,b = tuple(map(int,input().split())) x+=a y+=b print(*[x//n,y//n])
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n=int(input()) OBE=[list(map(int,input().split())) for i in range(n)] CL=[list(map(int,input().split())) for i in range(n)] OBE.sort(key=lambda x:x[1]) OBE.sort(key=lambda x:x[0]) CL.sort(key=lambda x:x[1]) CL.sort(key=lambda x:x[0]) print(OBE[0][0]+CL[-1][0],OBE[0][1]+CL[-1][1])
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) u = 0 v = 0 for i in range(n): x, y = map(int, input().split()) u += x v += y for j in range(n): a, b = map(int, input().split()) u += a v += b print(str(int(u/n)),str(int(v/n)))
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input().strip()) sum_x = 0 sum_y = 0 for _ in range(2*n): xy = list(map(int, input().strip().split())) sum_x += xy[0] sum_y += xy[1] print('{} {}'.format(int(sum_x / n), int(sum_y / n)))
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) a, b = 0, 0 for _ in range(2 * n): x, y = map(int, input().split()) a += x b += y print(a // n, b // n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class main { public static void main(String[] args) { // TODO Auto-generated method stub out=new PrintWriter (new BufferedOutputStream(Syst...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3 + 5; int N; int x[MAXN], y[MAXN]; int a[MAXN], b[MAXN]; int get(int *p, int *q) { return *min_element(p, p + N) + *max_element(q, q + N); } int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d%d", x + i, y + i); for (int i = 0; i ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.io.*; import java.math.*; import java.util.*; public class newYear { public static void main(String[] args) throws IOException { FastScanner sc = new FastScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int num = sc.nextInt(); long sum1 = 0; ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) ob = [] q = [] for i in range(n): ob.append(list(map(int, input().split()))) for i in range(n): q.append(list(map(int, input().split()))) ob.sort() q.sort(reverse=True) print(ob[0][0] + q[0][0], ob[0][1] + q[0][1])
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n,y,m,x=-10000000,-10000000,10000000,10000000 d=int(input()) for _ in range(d): a,b=map(int,input().split()) m=min(m,a) x=min(x,b) for _ in range(d): a,b=map(int,input().split()) n=max(n,a) y=max(y,b) print(m+n,x+y)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int x[n]; int y[n]; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } int a[n]; int b[n]; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } map<pair<int, int>, int> mp; pair<int, int> ans; for (int i = 0;...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.*; import java.io.*; public class Test { public static boolean isPrime(long num) { if (num == 2 || num == 3) return true; if (num % 2 == 0) return false; for (long i = 3; i * i <= num; i += 2) { if (num % i == 0) return fa...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int n, a[1111], b[1111], c[1111], d[1111]; vector<pair<int, int> > t1, t2; void chk(int x, int y) { t1.clear(); t2.clear(); for (int i = 1; i <= n; ++i) { t1.push_back((pair<int, int>){c[i], d[i]}); t2.push_back((pair<int, int>){x - a[i], y - b[i]}); } sor...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import java.util.*; public class Solution { static class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } } public static String solution(Point[] coordinates, Point[] direction) { Map<String, Integer> count = new Ha...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
from collections import Counter def plus(a, b): return a[0] + b[0], a[1] + b[1] def minus(a, b): return a[0] - b[0], a[1] - b[1] n = int(input()) points = [] vectors = [] for i in range(n): points.append(tuple(map(int, input().split()))) for i in range(n): vectors.append(tuple(map(int, input().sp...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Vll = vector<ll>; using VVll = vector<Vll>; using Pll = pair<ll, ll>; ll mdc(ll a, ll b) { if (a == 0) return b; else if (b == 0) return a; else { if (a < b) swap(a, b); a = a % b; return mdc(a, b); } } ll ms = 1123; i...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) c = [] d = [] for i in range(n): x,y = map(int, input().split()) c.append((x, y)) opt = {} for i in range(n): x,y = map(int, input().split()) d.append((x, y)) for ic in c: k = (x+ic[0], y + ic[1]) if k not in opt: opt[k] = 0 opt[k] += 1 for o in ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n = int(input()) x, y = 0, 0 for _ in range(2*n): dx, dy = map(int, input().split()) x += dx y += dy print(x//n, y//n)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { private static class Point{ int x; int y; public Point(){} ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n=int(input()) d1={} d2={} l1=[] l2=[] for i in range(n): a,b=map(int,input().split()) l1.append((a,b)) d1[(a,b)]=1 for i in range(n): a,b=map(int,input().split()) l2.append((a,b)) d2[(a,b)]=1 i=l1[0] flag=0 for j in l2: t=(i[0]+j[0],i[1]+j[1]) #print (t,d2) for k in l1: #print (k) if (t[0]-k[0],t[1]-k[1])...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
n=int(input()) xy=[];ab=[] for i in range(n): xy.append(list(map(int,input().split()))) for i in range(n): ab.append(list(map(int,input().split()))) ans=[] for i in xy: for j in ab: ans.append((i[0]+j[0],i[1]+j[1])) d={} for i in ans: if i in d: d[i]+=1 if d[i]==n: pr...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; long long x = 0, y = 0; long long t = n * 2; while (t--) { long long xx, yy; cin >> xx >> yy; x += xx; y += yy; } cout << x / n << " " << y / n << endl; }
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > heapp; priority_queue<pair<int, int> > heapp2; vector<int> tree[100006]; vector<pair<int, int> > tree1[100006]; class comp { public: bool operator()(pair<int, int> n1, p...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
import math mx=math.inf my=math.inf n=int(input()) for i in range(n): x,y=input().split() x=int(x) y=int(y) mx=min(x,mx) my=min(y,my) ax=-math.inf ay=-math.inf for i in range(n): x,y=input().split() x=int(x) y=int(y) ax=max(x,ax) ay=max(y,ay) print(mx+ax,my+ay)
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; inline int read() { int Res = 0, f = 1; char ch = getchar(); while (ch > '9' || ch < '0') f = (ch == '-' ? -f : f), ch = getchar(); while (ch >= '0' && ch <= '9') Res = Res * 10 + ch - '0', ch = getchar(); return Res * f; } int N; struct ad { int x, y; friend ...
Problem: Bob is a pirate looking for the greatest treasure the world has ever seen. The treasure is located at the point T, which coordinates to be found out. Bob travelled around the world and collected clues of the treasure location at n obelisks. These clues were in an ancient language, and he has only decrypted th...
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; pair<int, int> ob[n]; pair<int, int> dir[n]; int x, y; for (int i = 0; i < n; i++) { c...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
import java.io.*; import java.util.*; import java.math.*; import java.text.DecimalFormat; import java.text.NumberFormat; public class Main { int mod = 1000000007; public class SegmentTree{ int n; int[] tree; SegmentTree(int[] arr){ this.n = arr.length; this...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; int parent[100005]; int coun[100005]; bool isLucky(int a) { while (a) { int x = a % 10; if (x == 4 || x == 7) { } else return false; a = a / 10; } return true; } int findp(int a) { if (parent[a] == a) { return a; } parent[a] = findp(par...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 10, mod = 1e9 + 7; long long fact[maxn], inv[maxn]; long long par[maxn], sz[maxn]; long long bigmod(long long a, long long b, long long m) { if (b == 0) return 1; long long x = bigmod(a, b / 2, m); x = (x * x) % mod; if (b & 1) x = (x * ...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; int n; struct Node { int u, w, next; }; struct Node node[300010]; int p; int f[100010], g[100010], num[100010], isgo[100010]; int judge(int n) { while (n) { if (n % 10 != 4 && n % 10 != 7) return 0; n /= 10; } return 1; } void dfs(int u) { isgo[u] = 1; n...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; inline bool check(int x) { for (; x; x /= 10) if (x % 10 != 4 && x % 10 != 7) return 0; return 1; } const int maxn = 100100; int head[maxn], nxt[maxn << 1], ver[maxn << 1], val[maxn << 1], tot; inline void addedge(int a, int b, int c) { nxt[++tot] = head[a]; ver...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; inline long long get_num(char ch) { if (ch == '-') return 0; else if (ch >= 'a' && ch <= 'z') { return 1 + (ch - 'a'); } else if (ch >= 'A' && ch <= 'Z') { return 27 + (ch - 'A'); } else if (ch >= '0' && ch <= '9') { return 53 + (ch - '0'); } } inl...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.fill; import static java.lang.Math.*; import static java.util.Arrays.sort; import static java.util.Collections.sort; public class C109_dp { public static int mod = 1000000007; public static long INF = (1L << 60); static Fa...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:102400000,102400000") #pragma warning(disable : 4996) using namespace std; const int maxn = 2e5 + 5; const long long mod = 1e9 + 7; const double PI = acos(-1.0); long long po(long long a, long long b, long long mod) { long long res = 1; a %= mod; for (; b; ...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
// practice with rainboy import java.io.*; import java.util.*; public class CF109C extends PrintWriter { CF109C() { super(System.out, true); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF109C o = new CF109C(); o.main(); o.flush(); } int[] dsu; int find(int i) { return dsu[i]...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; vector<long long int> f, siz, f1; vector<vector<pair<int, int> > > graph; long long int ans; bool isLucky(int w) { int r; while (w) { r = w % 10; if (r != 4 && r != 7) return false; w /= 10; } return true; } void dfs(int in, int par) { siz[in] = 1; f...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; bool isLucky(int n) { if (n == 0) return false; while (n != 0) { if (n % 10 != 4 && n % 10 != 7) return false; n /= 10; } return true; } long long num; vector<int> a[100010]; bool mark[100010]; void cdfs(int k) { mark[k] = 1; int i; num++; for (i = 0...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; vector<int> L[100005], W[100005]; bool vis[100005]; long long comp; bool isLucky(int n) { while (n > 0) { if (n % 10 != 4 && n % 10 != 7) return false; n /= 10; } return true; } void DFS(int node) { if (vis[node]) return; vis[node] = true; comp++; for ...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
#include <bits/stdc++.h> using namespace std; const long long INF = 1e9, MOD = INF + 7; long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); } long long mod(long long n) { while (n < 0) n += MOD; return n % MOD; } const long long N = 1e5 + 20; vector<long long> g[N]; bool marked[N]; bool isLuck...
Problem: Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya encountered a tree with n vertexes. Besides, the tree was weighted, i. e. eac...
import java.util.*; import java.io.*; public class Main { static int n; static ArrayList<Integer>graph[]=new ArrayList[150000]; public static void main(String[] args) throws IOException{ BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWrit...