prompt
string
response
string
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class A { static int dis(int x,int y,int x2,int y2){ return Math.abs(x-x2)+Math.abs(y-y2); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x1= sc.nextInt(); int y1 = sc.nextInt(); int x2 = sc.nextInt(); int y2 = sc.nextInt(); ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; /** * Created by dtnha on 10/20/2017. */ public class QuadCopter { public static void main(String[] args) throws IOException { Reader.init(System.in)...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
/* * 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. */ import java.util.Scanner; /** * * @author my pc */ public class Contest883ProblemM { public static void main(String args[]) ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
a,b=map(int,raw_input().split()) c,d=map(int,raw_input().split()) delta=(abs(c-a)+abs(d-b)+2)*2 if a==c: delta+=2 if b==d: delta+=2 print delta
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int ans = 0; if (x2 == x1) { ans = 4 + 2 * (abs(y2 - y1) + 1); } else if (y2 == y1) { ans = 4 + 2 * (abs(x2 - x1) + 1); } else ans = (abs(y2 - y1) + 2 + abs(x2 - x1)) * 2; cout << ans; ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int x[] = {-1, 0, 1, 0, -1, 1, 1, -1}; int y[] = {0, -1, 0, 1, -1, 1, -1, 1}; int main() { ios::sync_with_stdio(false); int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int ans = 1e9; for (int i = 0; i < 8; i++) { int xx = x2 + x[i]; int yy = y2 + y[i]; ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.*; import java.util.Map.Entry; import java.lang.*; import java.math.*; import java.text.*; import java.io.*; public final class Solution { static PrintWriter out = new PrintWriter(System.out); static void flush() { out.flush(); } static class FastReader { BufferedReader br; Str...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a, b; cin >> a >> b; int s, d; cin >> s >> d; if (a > s) s++; else if (s > a) s--; if (b > d) d++; else if (b < d) d--; cout << abs(abs(a - s) * 2) + abs(abs(b - ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); int ans = abs(x2 - x1) + 1 + abs(y2 - y1) + 1; if (x2 == x1) { ans += 1; } if (y2 == y1) { ans += 1; } ans *= 2; cout << ans; return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class M883 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x1 = in.nextInt(); int y1 = in.nextInt(); int x2 = in.nextInt(); int y2 = in.nextInt(); int dx = Math.abs(x2-x1); int dy = Math.ab...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map( int, input().split()) x2, y2 = map( int, input().split()) if (x1-x2)==0 or (y1-y2)==0: print ((abs(x1-x2)+abs(y1-y2))*2+6) else: print ((abs(x1-x2)+abs(y1-y2))*2+4)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int x1, y1, x2, y2, ans = 0; cin >> x1 >> y1 >> x2 >> y2; if (x1 < x2) { if (y1 <= y2) ans = abs(x2 - 1 - x1) + abs(y2 - y1) + 5 + abs(x2 + 1 - x1) + abs(y2 - 1 - y1); else ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; template <class C> void mini(C &a4, C b4) { a4 = min(a4, b4); } template <class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); } template <class TH> void _dbg(const char *sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; } template <class TH, class... TA> void _dbg(const...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) if abs(x1 - x2) != 0 and abs(y1 - y2) != 0: print((abs(x1 - x2) + 1) * 2 + (abs(y1 - y2) + 1) * 2) else: print((abs(x1 - x2) + 1) * 2 + (abs(y1 - y2) + 1) * 2 + 2)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) if x1==x2 or -x1==-x2 or -y1==-y2: print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2+2) else: print((max(x2, x1)-min(x2,x1)+1)*2 +(max(y2, y1)-min(y2,y1)+1)*2)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.*; import java.io.*; import java.math.*; public class smack { InputStream is; PrintWriter out; int dx[]= {0,0,1,-1},dy[]={+1,-1,0,0}; static long mod=pow(10,9)+7; void solve() { int x1=ni(); int y1=ni(); int x2=ni(); int y2=ni(); int dist=Math.abs(x1-x2)+Math.abs(y1-y2); if(x1==x2||y1...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { long long x, y, a, b; cin >> x >> y >> a >> b; long long c = max(abs(a - x) + 1, 2ll), d = max(abs(b - y) + 1, 2ll); cout << 2ll * (c + d) << endl; return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e9 + 5; const int MOD = 1e9 + 7; const double PI = 3.14159265358979323846264338; const long long MAXN = 1e18; void solve(int t) { int a, b, c, d; cin >> a >> b >> c >> d; int ret1 = abs(a - c) + 1; int ret2 = abs(b - d) + 1; int ans1 = ret1 * 2; ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, a, b; cin >> m >> n >> a >> b; long long wea; long double d = sqrt(pow(m - a, 2) + pow(n - b, 2)); long double sdos = sqrt(2); if (d <= sdos) { wea = 8; } else { long long arreglo[2] = {m - a, n - b}; for (int i = 0; i ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); int x1, y1, x2, y2; x1 = cin.nextInt(); y1 = cin.nextInt(); x2 = cin.nextInt(); y2 = cin.nextInt(); int ans = 2* (Math.abs(x1-x2)+1 + Ma...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int x = abs(x1 - x2); int y = abs(y1 - y2); if (x == 0) { x = 1; } if (y == 0) { y = 1; } cout << (2 * (x + 1) + 2 * (y + 1)) << endl; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int x = max(2, abs(x1 - x2) + 1); int y = max(2, abs(y1 - y2) + 1); cout << 2 * x + 2 * y << endl; return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.*; import java.util.*; public class PP1 { static double eps = (double) 1e-6; public static void main(String[] args) throws FileNotFoundException{ InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); // InputReader in = new InputRead...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class M883 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int xSt = sc.nextInt(); int ySt = sc.nextInt(); int xEn = sc.nextInt(); int yEn = sc.nextInt(); int counter = 0; int x = xSt, y = ySt; if(xSt == xEn){ xS...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.*; import java.io.*; import java.math.*; import java.lang.*; import java.util.stream.*; /** * @author Pradyumn */ public class M implements Runnable{ public int TC = 0; public static void main(String[] args) { new Thread(null, new M(), ":)", 1L << 26).start(); } @SuppressWarnings("Unchecked...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.PrintStream; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public cl...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2; int ans = 2 * (abs(x1 - x2) + 1) + 2 * (abs(y1 - y2) + 1); if (x1 == x2) ans += 2; if (y1 == y2) ans += 2; cout << ans << "\n"; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
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...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int x[2][2]; int main() { for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) scanf("%d", x[i] + j); printf("%d\n", (max(1, abs(x[0][0] - x[1][0])) + max(1, abs(x[0][1] - x[1][1])) + 2) * 2); return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, aa, bb; cin >> a >> b; a += 100; b += 100; cin >> aa >> bb; aa += 100; bb += 100; if (aa != a && bb != b) { int tmp = (abs(a - aa)); int tmp2 = (abs(b - bb)); cout << 2 * abs(tmp2 + tmp) + 4; } else cout << max(8, (6 ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; cin >> a >> b >> c >> d; cout << 2 * (max(abs(a - c) + 1, 2)) + 2 * (max(abs(b - d) + 1, 2)) << "\n"; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; long long a = abs(x1 - x2); long long b = abs(y1 - y2); if (!a) a += 1; if (!b) b += 1; cout << (2 * (a + b + 2)) << endl; return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1,y1 = [int(xy) for xy in raw_input().split(" ")] x2,y2 = [int(xy) for xy in raw_input().split(" ")] dx = abs((x1+200)-(x2+200)) dy = abs((y1+200)-(y2+200)) # print dx,dy ans = (2*dx)+(2*dy)+8 if x1 != x2: ans -= 2 if y1 != y2: ans -= 2 print ans
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1); const long long N = 1e5 + 5, M = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long x, y, xx, yy, ans = 8; cin >> x >> y >> xx >> yy; ans += max(abs(xx - x) - 1, 0ll) * 2; ans += max(abs(yy - y) - 1, 0ll) * 2; ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.*; import java.security.SecureRandom; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out)); //String test = "D-large"; //Consol...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2) { int k = y2 - y1; if (k < 0) k = -k; k++; cout << 2 * k + 4; } else if (y1 == y2) { int k = x2 - x1; if (k < 0) k = -k; k++; cout << 2 * k + 4; } else { ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
I = lambda:map(int, raw_input().split()) x, y = I() a, b = I() print (max(abs(x - a), 1) + max(abs(y - b), 1)) * 2 + 4
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; const long double pi = acos(-1); long long x1, abc, x2, y2, ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> abc >> x1; cin >> y2 >> x2; if (x1 == x2) x1--; if (abc == y2) abc--; cout << (abs(x1 - x2) + abs(abc - y2)) * 2 + 4 << '\n'; return 0; ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException; import java.io.IOException;import java.io.InputStream;import java.io.PrintStream; import java.io.PrintWriter;import java.security.AccessControlException;public class _p000883M { static public void main(final String[] args) throws I...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
# -*- coding: utf-8 -*- import math import collections import bisect import heapq import time import random import itertools import sys """ created by shhuan at 2017/10/22 12:19 """ x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) print(2*(2+max(abs(x1-x2), 1)+max(abs(y1-y2), 1)))
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
I = lambda: map(int, input().split()) x1, y1 = I() x2, y2 = I() print(2 * (abs(x1-x2) + abs(y1-y2) + 2 + (x1==x2 or y1==y2)))
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1,y1=map(int,input().split()) x2,y2=map(int,input().split()) if(x1==x2): print(4+abs(y2-y1)*2+2) elif(y1==y2): print(4+abs(x2-x1)*2+2) else: print(abs(x2-x1)*2+abs(y2-y1)*2+4)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
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...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) print(2 *(max(2, abs(x1 - x2) + 1) + max(2, abs(y1 - y2) + 1)))
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int x, y, a, b, A[10]; int main() { scanf("%d%d", &x, &y); scanf("%d%d", &a, &b); A[1] = abs(x - (a - 1)) + abs(y - (b - 1)); A[2] = abs(x - (a - 1)) + abs(y - (b + 1)); A[3] = abs(x - (a + 1)) + abs(y - (b - 1)); A[4] = abs(x - (a + 1)) + abs(y - (b + 1)); so...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> template <typename Tp> void in(Tp &x) { char ch = getchar(), f = 1; x = 0; while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') f = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); x *= f; } template <typename Tp> bool c...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
from math import inf,sqrt,floor,ceil from collections import Counter,defaultdict,deque from heapq import heappush as hpush,heappop as hpop,heapify as h from operator import itemgetter from itertools import product from bisect import bisect_left,bisect_right x1,y1=map(int,input().split( )) x2,y2=map(int,input().split(...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.PrintWriter; import java.util.Scanner; public class M { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt(); PrintWriter out = new PrintWriter(System.out); if (x1 == x2) { out.println(4 ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
from sys import stdin x1,y1 = map(int,stdin.readline().split()) x2,y2 = map(int,stdin.readline().split()) ans = 2*(abs(x1-x2) + abs(y1-y2)) if x1==x2 and y1==y2: ans = 10 elif x1==x2 or y1==y2: ans = ans+6 else: ans+=4 print ans
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) if x1 == x2: x1 += 1 if y1 == y2: y1 += 1 ans = abs(x1 - x2) + abs(y1 - y2) + 2 print(2*ans)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x,y=map(int,input().split(' ')) a,b=map(int,input().split(' ')) print((max(abs(a-x),1)+max(abs(b-y),1))*2+4)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import javafx.util.Pair; import static java.lang.Double.parseDouble; import static java.lang.Double.valueOf; import static java.lang.Long.max; import static java.lang.Long.min; import static java.lang.Integer.max; import static java.lang.Integer.min; import static java.lang.Integer.parseInt; import static java.lang.Lo...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
helicopter = map(int,raw_input().split()) flag = map(int,raw_input().split()) #8 points to consider x = flag[0] y = flag[1] points = [[x-1,y+1],[x,y+1],[x+1,y+1],[x+1,y],[x+1,y-1],[x,y-1],[x-1,y-1],[x-1,y]] def dist(x,y): return abs(y[1]-x[1]) + abs(y[0]-x[0]) min = 1000 for i in points: if dist(i,helicopter...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1,y1=map(int,input().split()) x2,y2=map(int,input().split()) if x1==x2: print(2*(1+abs(y1-y2)+2)) elif y1==y2: print(2*(1+abs(x1-x2)+2)) else: print(2*(abs(x1-x2)+1+abs(y1-y2)+1))
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
//package CodeForce; import java.io.*; import java.util.*; public class ACMICPCNEERCA { static int[] A; static int[] S; static long[] sum; public static int mod=1000000007; static int[][] dp; static boolean[][] isPalin; static int max1=5000+10; static int[][] g; static int ver; static int...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; /* * 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 Paras */ public class ACM { public static void main(String args[]){ Sc...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
start = input().split() x1 = int(start[0]) y1 = int(start[1]) flag = input().split() x2 = int(flag[0]) y2 = int(flag[1]) print( 2*max(1, abs(x1-x2))+2 + 2*max(abs(y1-y2), 1)+2 )
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
read = lambda: tuple(map(int, input().split())) x1, y1 = read() x2, y2 = read() l = (-1, 0, 1) ds = [] dist = lambda a, b: max(a, b) - min(a, b) for i in l: for j in l: ds += [dist(x1, (x2+i)) + dist(y1, (y2+j))] print(min(ds) * 2 + 8)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int X1, Y1, X2, Y2; int main() { scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2); if (X1 != X2 && Y1 != Y2) printf("%d\n", 2 * abs(X1 - X2) + 2 * abs(Y1 - Y2) + 4); else if (X1 == X2 && Y1 == Y2) printf("%d\n", 10); else if (X1 == X2) printf("%d\n", 2 * abs(Y1 - Y...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int ans = 0; if (y1 == y2) { ans = (abs(x1 - x2) + 1) * 2 + 4; } else if (x1 == x2) { ans = (abs(y1 - y2) + 1) * 2 + 4; } else ans = 2 * (abs(x1 - x2) + 1) + 4 + 2 * (abs(y1 - y2) - 1); ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class Test { public static void main(String[] args) { int x1,x2,y1,y2; Scanner sc = new Scanner(System.in); x1 = sc.nextInt(); y1 = sc.nextInt(); x2 = sc.nextInt(); y2 = sc.nextInt(); int xdiffer = Math.abs(x2-x...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.*; import java.math.*; import java.util.*; import java.util.stream.*; @SuppressWarnings("unchecked") public class P883M { public void run() throws Exception { int x1 = nextInt(), y1 = nextInt(), x2 = nextInt(), y2 = nextInt(); println((Math.abs(x1 - x2) + Math.abs(y1 - y2) + (((x1 == x2) || (...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws IOException { FastScanner f = new FastScanner(); int x1 = f.nextInt(); int y1 = f.nextInt(); int x2 = f.nextInt(); int y2 = f.nextInt(); int d = 2*(Math.abs(x1-x2) + Math.abs(y1-y2))+4; if(x1 == x2 || y1 ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x, xx, y, yy; cin >> x >> y >> xx >> yy; if ((x == xx && abs(y - yy) == 1) || (y == yy && abs(x - xx) == 1)) { cout << 8 << endl; return 0; } else { if (x == xx && y > yy) cout << (2 * abs(x - xx)) + (2 * abs(y - (yy - 1))) + 4 << ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x_1, y_1 = map(int, raw_input().split()) x_2, y_2 = map(int, raw_input().split()) if x_1 == x_2 or y_1 == y_2: print((abs(x_2 - x_1) + abs(y_2 - y_1)) * 2 + 6) else: print((abs(x_2 - x_1) + abs(y_2 - y_1) + 2) * 2)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map(int, input().split()) x2, y2 = map(int, input().split()) a, b = abs(x1 - x2) + 1, abs(y1 - y2) + 1 if x1 == x2: a = 2 if y1 == y2: b = 2 print(2 * a + 2 * b)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x,y=map(int,input().split()) p,q=map(int,input().split()) ans = (abs(x-p)+abs(y-q)+2)*2 if x==p or y==q: ans+=2 print(ans)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1,y1=map(int,input().split()) x2,y2=map(int,input().split()) if x1!=x2 and y1!=y2: ans=2*(abs(x2-x1)+1)+2*(abs(y2-y1)+1) elif x1==x2: ans=2*(abs(y2-y1)+1)+4 else: ans=2*(abs(x2-x1)+1)+4 print(ans)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
n,k=map(int,input().strip().split(' ')) a,b=map(int,input().strip().split(' ')) print(2*(max(2,abs(a-n)+1)+max(2,abs(b-k)+1)))
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int x1, y1, x2, y2; cin >> x1 >> y1; cin >> x2 >> y2; int dst = abs(x1 - x2) + abs(y1 - y2) - 2; if (dst <= 0) cout << 8 << endl; else if (x1 == x2 || y1 == y2) cout << 2 * (dst + 1) + 8 << endl; else cout <...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.*; import java.util.*; public class QuadcopterCompetition { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class codeforces2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int xq = in.nextInt(); int yq = in.nextInt(); int xf = in.nextInt(); int yf = in.nextInt(); int s = 0; if (xq == xf){ ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; int ans = 0; if (x1 == x2 || y1 == y2) { ans = abs(x1 - x2) * 2 + abs(y1 - y2) * 2 + 6; } else { ans = abs(x1 - x2) * 2 + abs(y1 - y2) * 2 + 4; } cout << ans; return 0...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x, y = map(int, input().split()) x2, y2 = map(int, input().split()) result = (abs(x - x2) + abs(y - y2) + 2) * 2 if x == x2: result += 2 if y == y2: result += 2 print(result)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> int main() { int x1, x2, y1, y2; while (scanf("%d%d%d%d", &x1, &y1, &x2, &y2) == 4) { int ans = 0; if (x2 != x1 && y1 != y2) ans = (abs(x2 - x1) + abs(y2 - y1) + 2) * 2; else if (x2 == x1) { ans = (abs(y2 - y1) + 1) * 2 + 4; } else ans = (abs(x1 - x2) + 1) ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x, y, x2, y2; cin >> x >> y >> x2 >> y2; int sol = 2 * abs(x2 - x) + 2 * abs(y2 - y) + 4; if (x == x2 or y == y2) sol += 2; cout << sol << '\n'; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokeniz...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
s = input() xy1 = s.split() xy1[0] = int(xy1[0]) xy1[1] = int(xy1[1]) s = input() xy2 = s.split() xy2[0] = int(xy2[0]) xy2[1] = int(xy2[1]) if(xy1[0]==xy2[0] and xy1[1]==xy2[1]): print(10) elif(xy1[0]==xy2[0] and xy1[1]!=xy2[1]): dify = xy2[1]-xy1[1] if(dify < 0): dify = -1*dify dify = dify + 1 ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import math import re def ria(): return [int(i) for i in input().split()] def ri(): return int(input()) def rfa(): return [float(i) for i in input().split()] eps = 1e-9 def is_equal(a, b): return abs(a - b) <= eps def distance(p0, p1): return math.sqrt((p0[0] - p1[0]) ** 2 + (p0[1] - p1[...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
# Je ne trouve pas l'astuce... :/ def dist(x1, y1, x2, y2): return abs(x2 - x1) + abs(y2 - y1) x, y = map(int, input().split()) a, b = map(int, input().split()) r = 4 + 2 * dist(x, y, a, b) if x == a or y == b: r += 2 print(r)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); int a1 = abs(a - c) * 2; int b1 = abs(b - d) * 2; int ans = a1 + b1 + 4; if (a != c && b != d) printf("%d\n", ans); else printf("%d\n", ans + 2); return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int dist(pair<long long int, long long int> a, pair<long long int, long long int> b) { int ret = 0; ret += abs(a.first - b.first); ret += abs(a.second - b.second); return ret; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner cin = new Scanner(System.in); int x1, y1, x2, y2; x1 = cin.nextInt(); y1 = cin.nextInt(); x2 = cin.nextInt(); y2 = cin.nextInt(); int ans = 2* (Math.abs(x1-x2)+1 + Ma...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> #pragma comment(linker, "/stack:640000000") using namespace std; const double EPS = 1e-9; const int INF = 0x7f7f7f7f; const double PI = acos(-1.0); 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...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
function abs(q) { if (q>0){return q;} return -q } s=readline().split(' ').map(function(x){return +x;}) a=+s[0] b=+s[1] s=readline().split(' ').map(function(x){return +x;}) c=+s[0] d=+s[1] u=0 if (a==c||b==d) { u=2 } print(abs(a-c)*2+abs(b-d)*2+4+u)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { int x1, y1, x2, y2; scanf("%d %d %d %d", &x1, &y1, &x2, &y2); int x = abs(x1 - x2); x++; int y = abs(y1 - y2); y++; if (x == 1) x++; if (y == 1) y++; int ans = (x + y) << 1; printf("%d\n", ans); return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; void solve() { int a, b, x, y; cin >> a >> b >> x >> y; if (abs(a - x) <= 1 && abs(b - y) <= 1) cout << 8; else { int ans = 8; if (a != x) ans += abs(a - x) * 2 - 2; if (b != y) ans += abs(b - y) * 2 - 2; cout << ans; } } int main() { int t =...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
x1, y1 = map(int, raw_input('').split(' ')) x2, y2 = map(int, raw_input('').split(' ')) x1 = x1+101 y1 = y1+101 x2 = x2+101 y2 = y2+101 x = 0 y = 0 wyn = 0 x = abs(x2 - x1) + 1 y = abs(y2 - y1) + 1 if x == 1: x = 2 if y == 1: y = 2 wyn = 2*x + 2*y print wyn
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
# -*- coding: utf-8 -*- """ Created on Sat Oct 21 11:00:49 2017 @author: sven """ x1,y1=map(int,input().split()) x2,y2=map(int,input().split()) x=max(abs(x2-x1)+1,2) y=max(abs(y2-y1)+1,2) print((x+y)*2)
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
//>>>BaZ<<<// import java.util.*; import java.io.*; import static java.lang.Math.*; public class Main { static int dx[] = {-1,1,0,0}; static int dy[] = {0,0,1,-1}; static long MOD = 1000000007; static int INF = Integer.MAX_VALUE/10; static PrintWriter pw; static Reader scan; static int ni(...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; const int maxint = 2147483647; const int minint = -2147483647; const unsigned int maxunint = 4294967295; int main() { int x1, y1, x2, y2, d; cin >> x1 >> y1 >> x2 >> y2; if (y1 > y2) { if (x1 > x2) { d = 2 * (y1 - y2 + 1 + x1 - x2 + 1); } else { if...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.util.Scanner; public class FirstTask { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x1 = sc.nextInt(); int y1 = sc.nextInt(); int x2 = sc.nextInt(); int y2 = sc.nextInt(); int transX = (x1 == x2) ? (4) : (2 * (Math.abs(x2 - x1) + 1)); int transY = (y1 ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int st(int x, int pos) { return x = x | (1 << pos); } int Reset(int x, int pos) { return x = x & ~(1 << pos); } int main() { long long x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; if (x1 == x2) { cout << 4 + 2 * (abs(y1 - y2) + 1) << endl; } else if (y1 == y2) {...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2); int xn = max(abs(x1 - x2) + 1, 2); int yn = max(abs(y1 - y2) + 1, 2); printf("%d\n", xn * 2 + yn * 2); return 0; }
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1; cin >> x2 >> y2; if (x2 > x1 && y2 < y1) { x2 = x2 + 1; y2 = y2 - 1; } if (x2 > x1 && y2 > y1) { x2 = x2 + 1; y2 = y2 + 1; } if (x2 < x1 && y2 < y1) { x2 = x2 - 1; y2 = y2 - 1; } i...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class M883 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
import java.io.*; import java.util.*; /* TASK: CFM LANG: JAVA */ public class CFM { static int x1 , y1 , x2 , y2; public static void main(String[] args) throws IOException { FastScanner in = new FastScanner(System.in); x1 = in.nextInt(); y1 = in.nextInt(); x2 = in.nextInt(); ...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
#include <bits/stdc++.h> using namespace std; bool dist(int x1, int y1, int x2, int y2) { if (x1 == x2 && (y1 == y2 + 1 || y2 == y1 + 1)) return 1; if (y1 == y2 && (x1 == x2 + 1 || x2 == x1 + 1)) return 1; return 0; } int sameline(int x1, int y1, int x2, int y2) { if (x1 == x2) return 2 * (2 + abs(y1 - y2) + 1)...
Problem: Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: * start the race from some point of a field, * go around the flag, * close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1, y1) and the coordinates of...
cc = list(map(int, input().split())) fc = list(map(int, input().split())) print(2*(((abs(fc[0] - cc[0]) if fc[0] - cc[0] != 0 else 1) + 1) + ((abs(fc[1] - cc[1]) if fc[1] - cc[1] != 0 else 1) + 1)))