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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class TaskM {
private static BufferedReader in;
private static StringTokenizer tok;
private static PrintWriter out;
public static String re... |
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.*;
public class Main{
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
int x1,x2,y1,y2;
x1=sc.nextInt();
y1=sc.nextInt();
x2=sc.nextInt();
y2=sc.nextInt();
if(Math.abs(x1-x2)<=1 && Math.abs(y1-y2)<=1){
Sys... |
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)=(int(i) for i in (input().split()))
(c,d)=(int(i) for i in (input().split()))
if a==c or b==d:
k=((((c-a)**2)**(1/2))+(((d-b)**2)**(1/2)))*2+6
else:
k=((((c-a)**2)**(1/2))+(((d-b)**2)**(1/2)))*2+4
d=k**2
print(int(d**(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... | x1, y1=map(int, raw_input().split()); y=1;
x2, y2=map(int, raw_input().split())
if (x2==x1) and (y2==y1):
print 8
else:
if (x2==x1) or (y2==y1):
print 2*(abs(x2-x1)+abs(y2-y1))+6
else:
print 2*(abs(x2-x1)+abs(y2-y1))+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(0);
cin.tie(0);
cout.tie(0);
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
long long ans = 0;
if (x1 == x2) {
ans += 4;
} else {
int gg = abs(x2 - x1);
gg++;
gg *= 2;
ans += gg;
}
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;
cin >> x1 >> y1 >> x2 >> y2;
int u = max(y2 + 1, y1);
int d = min(y2 - 1, y1);
int r = max(x2 + 1, x1);
int l = min(x2 - 1, x1);
cout << 2 * (u - d + r - l);
}
|
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... | '''input
0 1
0 0
'''
from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
import m... |
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.*;
public class Main {
public static void main(String[] args) throws Exception {
int x=sc.nextInt();
int y=sc.nextInt();
int x2=sc.nextInt();
int y2=sc.nextInt();
int ans=(Math.abs(x-x2)+Math.abs(y-y2)-1)*2+8;
if(x2!=x&&y2!=y)ans-=2;
pw.println(ans);
pw.close();
... |
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 aVal(int x) {
if (x > 0) return x;
if (x < 0) return -x;
if (x == 0) return 0;
}
int main() {
int Xq, Yq, Xf, Yf;
cin >> Xq >> Yq >> Xf >> Yf;
if (aVal(Xq - Xf) <= 1 && aVal(Yq - Yf) <= 1) {
cout << 8 << endl;
return 0;
}
if (Xq >= Xf && Yq >= Yf... |
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 ProblemM {
private static int startX, startY;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int flagX, flagY, needPointX, needPointY;
startX = scanner.nextInt();
startY = scanner.nextInt();
scann... |
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.*;
public class AUD
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
int x1=s.nextInt();
int y1=s.nextInt();
int x2=s.nextInt();
int y2=s.nextInt();
int ans=((Math.abs(x1-x2)+1)*2+(Math.abs(y1-y2)+1)*2);
if(x1==x2||y1==y2)System.out.println(ans+2);
else S... |
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())
def abs(a,b):
if a > b:
return a - b
else:
return b - a
if x1 != x2 and y1 != y2:
print(2*(abs(x1,x2)+1)+2*(abs(y1,y2)+1))
elif x1 == x2:
print(4*(abs(x1,x2)+1)+2*(abs(y1,y2)+1))
elif y1 == y2:
print(2*(abs(x1,x2)+1)+4*(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 main() {
int x1, y1;
int x2, y2;
int sum = 0;
cin >> x1 >> y1;
cin >> x2 >> y2;
int a = abs(x1 - x2);
if (a == 0) a = 1;
int b = abs(y1 - y2);
if (b == 0) b = 1;
sum += a * 2 + 2;
sum += b * 2 + 2;
cout << sum << 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;
int a, b, c, d, s1, s2;
int main() {
cin >> a >> b >> c >> d;
s1 = abs(a - c);
s2 = abs(b - d);
if (s1 == 0)
s1 = 2;
else
s1++;
if (s2 == 0)
s2 = 2;
else
s2++;
printf("%d\n", 2 * (s1 + s2));
}
|
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 int i, j, k, l, n, m;
long long int a, b, c, d;
cin >> a >> b >> c >> d;
l = abs(c - a) + 1;
k = abs(d - b) + 1;
if (a == c) l++;
if (b == d) k++;
cout << 2 * (l + k);
}
|
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
*
* @author Satyam Bharadwaj
*/
public class Main {
public static void main(String[] args) {
Inpu... |
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.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int x1,y1,x2,y2;
x1 = input.nextInt();
y1 = input.nextInt();
x2 = input.nextInt();
y2 = input.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.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class SolutionA extends Thread {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new 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;
const long long mod = 1e9 + 7;
bool isPrime[1000005] = {false};
vector<long long> prm;
vector<long long> SPF(1000005);
void sieve() {
isPrime[1] = isPrime[0] = 0;
long long i;
for (i = 2; i < 1000005; ++i) isPrime[i] = 1;
for (i = 2; i * i < 1000005; ++i) {
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... | x1, y1 = map(int, input().split())
x2, y2 = map(int, input().split())
print(2 * (max(1, abs(x1 - x2)) + 1) + 2 * (max(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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int pathX = 0;
if (x1 == x2) x1++;
pathX = abs(x1 - x2) + 1;
int pathY = 0;
if (y1 == y2) y1++;
pathY = abs(y1 - y2) + 1;
cout << 2 * (pathX + pathY);
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 n;
struct point {
long long x, y;
point(){};
point(long long nx, long long ny) : x(nx), y(ny){};
point operator-(point p) { return point(p.x - x, p.y - y); }
};
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
long long x1, y1, x2, 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 dist(int x1, int y1, int x2, int y2) {
return abs(x1 - x2) * 2 + abs(y1 - y2) * 2;
}
int main() {
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 > x2 && y1 > y2) {
cout << dist(x1, y1, x2 - 1, y2 - 1);
}
if (x1 < x2 && y1 < y2) {
cout << dis... |
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 ax, ay, bx, by;
int main() {
scanf("%d%d%d%d", &ax, &ay, &bx, &by);
printf("%d\n", 2 * (max(1, abs(ax - bx)) + max(1, abs(ay - by)) + 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;
void mod1(long long int &a) { a %= 1000000007; }
void mod2(long long int &a) {
a %= 1000000007;
if (a < 0) {
a += 1000000007;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> 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... | #include <bits/stdc++.h>
using namespace std;
int fabs(int x) { return x > 0 ? x : -x; }
int main() {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
int w = fabs(x1 - x2) + 1;
int h = fabs(y1 - y2) + 1;
if (w == 1) w++;
if (h == 1) h++;
printf("%d\n", 2 * w + 2 * h);
}
|
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 sys
def main():
a, b = map(int, sys.stdin.readline().split())
c, d = map(int, sys.stdin.readline().split())
k = abs(a - c) + 1
if k == 1:
k += 1
r = abs(b - d) + 1
if r == 1:
r += 1
print(2 * (k + r))
main()
|
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 INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch<'0' | ch> '9') {
if (ch == '-') f = -1;
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... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
struct Rcompare {
bool operator()(pair<int, int> lhs, pair<int, int> rhs) {
return lhs.first > rhs.first;
}
};
struct compare {
bool operator()(pair<int, int> lhs, pair<int, int> rhs) {
... |
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;
set<string> str;
vector<char> s1, s2;
char S1[1000000], S2[1000000];
int a, b, c, d;
int main() {
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
int x = max(abs(c - a) + 1, 2);
int y = max(abs(d - b) + 1, 2);
printf("%d\n", 2 * (x + y));
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, x2, y1, y2, ans;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
if (x1 == x2) {
ans = 4 + (abs(y1 - y2) + 1) * 2;
} else if (y1 == y2) {
ans = 4 + (abs(x1 - x2) + 1) * 2;
} else
ans = (abs(x1 - x2) + abs(y1 - y2) + 2) * 2;
printf("%d\... |
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())
a,b=I()
c,d=I()
print((max(1,abs(a-c))+max(1,abs(b-d))<<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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 != x2 && y1 != y2)
cout << 2 * (abs(x1 - x2) + abs(y1 - y2)) + 4 << endl;
else
cout << 2 * (abs(x1 - x2) + abs(y1 - y2)) + 6 << 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;
int main() {
int x1, y1;
int x2, y2;
cin >> x1 >> y1;
cin >> x2 >> y2;
int arr[4];
arr[0] = abs(x1 - x2 - 1) + abs(y1 - y2 - 1);
arr[1] = abs(x1 - x2 + 1) + abs(y1 - y2 - 1);
arr[2] = abs(x1 - x2 - 1) + abs(y1 - y2 + 1);
arr[3] = abs(x1 - x2 + 1) + abs(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... | x, y = map(int , raw_input().split())
x1 , y1 = map(int , raw_input().split())
res = 0
if x == x1 or y == y1:res = 2
print (abs(x -x1) + abs(y - y1))*2 + 4 + res |
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 codeforces;
import java.util.*;
public class cf883M
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int sx = in.nextInt();
int sy = in.nextInt();
int dx = in.nextInt();
int dy = in.nextInt();
int minDis = 2;
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... | x1,y1 = map(int, raw_input().split())
x2,y2 = map(int, raw_input().split())
print (abs(x2-x1)+1+(x2==x1))*2+(abs(y2-y1)+1+(y2==y1))*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())
ans = 2 * ( abs(x1-x2) + abs(y1-y2)-1 ) + 6
if x1 == x2 or 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... |
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
if(a[0] == b[0]):
x = ((abs(b[1] - a[1])) + 1 + 2 ) * 2
print(x)
elif(a[1] == b[1]):
x = ((abs(b[0] - a[0])) + 1 +2 ) * 2
print(x)
else:
x = ((abs(b[0]-a[0])+1) + abs(b[1] - a[1]) + 1)*2
print(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... | #include <bits/stdc++.h>
using namespace std;
vector<int> vec[1001];
vector<bool> vis;
int main() {
int tc, cse = 0;
{
int x, y, m, n;
cin >> x >> y >> n >> m;
int dis1 = abs(x - n);
int dis2 = abs(y - m);
dis1++, dis2++;
if (x == n or y == m)
cout << dis1 * 2 + dis2 * 2 + 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... | import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import add
inf = float("inf")
# input = sys.stdin.readline
flush = lambda: sys.stdout.flush
comb = lambda x, y: (factorial(x) // factorial(y)) // factorial(x - y)
# inputs
# ip = lam... |
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;
int ans = 2 * (abs(a - c) + abs(b - d) + 2);
if (a == c) ans += 2;
if (b == d) ans += 2;
cout << ans << 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... | depart = list(map(int,input().split()))
drapeau = list(map(int,input().split()))
if (drapeau[1]==depart[1]):
print(4+2*(abs(max(drapeau[0],depart[0])-min(drapeau[0],depart[0])+1)))
elif(drapeau[0]==depart[0]):
print(4+2*(abs(max(drapeau[1],depart[1])-min(drapeau[1],depart[1])+1)))
else :
print(2*(abs(max(... |
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;
if ((fabs(a - c) == 1 && fabs(b - d) == 0) ||
(fabs(a - c) == 0 && fabs(b - d) == 1)) {
cout << 2 * (fabs(a - c) + fabs(b - d)) + 4 + 2;
} else if (a == c || b == d) {
cout << 2 * (fabs(a - c) + fab... |
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;
scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
long long ans = 2 * ((abs(x1 - x2) + 1) + (abs(y1 - y2) + 1));
if (x1 == x2 || y1 == y2) {
ans += 2;
}
printf("%lld\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;
int main() {
int a, b, x, y;
cin >> a >> b >> x >> y;
int dist = 0;
if (a != x)
dist += 2 * (abs(a - x) + 1);
else
dist += 4;
if (b != y)
dist += 2 * (abs(b - y) + 1);
else
dist += 4;
cout << dist << 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 = list(map(int, input().split()))
x2, y2 = list(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 main() {
long long a, b, c, d;
cin >> a >> b >> c >> d;
if (a == c) {
long long y = 1;
long long z = abs(b - d);
cout << 2 * (y + 1) + 2 * (z + 1);
return 0;
}
if (b == d) {
long long y = abs(a - c);
long long z = 1;
cout << 2 * (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... | a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
def abs(v):
return max(v, -1 * v )
print 2 * (1 + (a == c) + abs(a - c)) + 2 * (1 + (b == d) + abs(b - d))
|
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... | z=lambda:map(int,input().split())
d=lambda a,b:max(abs(a-b)+1,2)
q,w=z()
e,r=z()
print((d(q,e)+d(w,r))*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())
q=x1==x2 or y1==y2
if x2<x1:
x2-=1
elif x2>x1:
x2+=1
if y2<y1:
y2-=1
elif y2>y1:
y2+=1
print(abs(x2-x1)*2+abs(y2-y1)*2+4 if q else abs(x2-x1)*2+abs(y2-y1)*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() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int dx = abs(x1 - x2) + 1;
if (x1 == x2) dx++;
int dy = abs(y1 - y2) + 1;
if (y1 == y2) dy++;
cout << (dx + dy) * 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() {
int x1, x2, y1, y2;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
if (x1 != x2 && y1 != y2)
cout << (abs(x1 - x2) + abs(y1 - y2)) * 2 + 4;
else if (x1 == x2)
cout << (4 + 2 * (abs(y1 - y2) + 1));
else
cout << (4 + 2 * (abs(x1 - x2) + 1));
re... |
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 = input().split()
x_2,y_2 = input().split()
x_1 = int(x_1)
x_2 = int(x_2)
y_1 = int(y_1)
y_2 = int(y_2)
if x_1 == x_2:
jwb = 2*(abs(y_2-y_1)+1) + 4
elif y_1 == y_2:
jwb = 2*(abs(x_2-x_1)+1) + 4
else:
jwb = 2*(abs(x_2-x_1)+1) + 2*(abs(y_2-y_1)+1)
print(jwb)
|
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
rints = lambda: [int(x) for x in stdin.readline().split()]
x1, y1 = rints()
x2, y2 = rints()
print((max(abs(x1 - x2), 1) + max(abs(y1 - y2), 1) + 2) << 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, x2, y2;
int main() {
cin >> x >> y;
cin >> x2 >> y2;
cout << 2 * (abs(x2 - x) + abs(y2 - y) + 2 + (x == x2 || y == y2 ? 1 : 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, s = 0;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 == x2)
s += 2;
else
s += abs(x1 - x2) + 1;
if (y1 == y2)
s += 2;
else
s += abs(y1 - y2) + 1;
cout << s * 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... | #!/usr/bin/env python
x1,y1 = map(int, raw_input().split())
x2,y2 = map(int, raw_input().split())
result = 2*abs(x1-x2) + 2*abs(y1-y2)
if (x1>=x2):
result += 2
if (x1<=x2):
result += 2
if (y1>=y2):
result += 2
if (y1<=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... | x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
d1=(abs(x1-x2)+1)*2
d2=(abs(y1-y2)+1)*2
if (x1==x2) or (y1==y2):
print(d1+d2+2)
else:
print(d1+d2)
|
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... | def main():
x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
res = (abs(x2-x1) + abs(y2 - y1) +2)*2
if x1==x2:
res +=2
if y1 == y2:
res +=2
print( res)
main() |
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 take() {
int n;
scanf("%d", &n);
return n;
}
double ttake() {
double n;
scanf("%lf", &n);
return n;
}
long long takes() {
long long n;
scanf("%lld", &n);
return n;
}
int cas;
using namespace std;
bool approximatelyEqual(float a, float b, float epsilon) {
return fabs(a - ... |
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.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Main {
static BufferedReader br;
static StringTokenizer 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 Problem883M {
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[][] moves = {{-1, -1}, {1, 1}, {1, -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... | x1,y1=map(int, input().split())
x2,y2=map(int, input().split())
travelx=(abs(x1-x2))
travely=(abs(y1-y2))
if(travelx==0):
travelx+=2
else:
travelx+=1
if(travely==0):
travely+=2
else:
travely+=1
travelx*=2
travely*=2
print(travelx+travely) |
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 y1 == y2:
print(6+2*abs(x1-x2)+2*abs(y1-y2))
else:
print(4+2*abs(x1-x2)+2*abs(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... | a, b = map(int, raw_input().split())
c, d = map(int, raw_input().split())
e = (abs(a - c) + abs(b - d) + 2) * 2
if a == c or b == d:
e += 2
print e |
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(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
print(max(abs(x1 - x2) + 1, 2) * 2 + max(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())
dx = max(2, abs(x1-x2) + 1)
dy = max(2, abs(y1-y2) + 1)
print(dx*2 + dy*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;
long long mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int, int> fib(int n) {
if (n == 0) return {0, 1};
auto p = fib(n >> 1);
int c = p.first * (2 * p.second - p.first);
int d = p.first * p.first + p.second * p.second;... |
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 long int INF = 1E10;
int abs(int x) {
int ans = (x < 0) ? -x : x;
return ans;
}
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int dx = abs(x1 - x2);
int dy = abs(y1 - y2);
if (dx <= 1) {
if (dy <= 1)
cout << "8" << 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... | x1, y1 = map(int, input().split(' '))
x2, y2 = map(int, input().split(' '))
gotox = x2
gotoy = y2
if x1 > x2:
gotox -= 1
elif x2 > x1:
gotox += 1
if y1 > y2:
gotoy -= 1
elif y2 > y1:
gotoy += 1
print((max(abs(x1 - gotox), 2) + max(abs(y1 - gotoy), 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... | 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, x2, y1, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 == x2) {
cout << ((2 + (abs(y1 - y2) + 1))) * 2 << endl;
} else if (y1 == y2)
cout << ((2 + (abs(x1 - x2) + 1))) * 2 << endl;
else
cout << ((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... | #include <bits/stdc++.h>
using namespace std;
int ax, ay, bx, by;
int main() {
while (scanf("%d %d", &ax, &ay) != EOF) {
scanf("%d %d", &bx, &by);
int h = max(2, abs(ax - bx) + 1), v = max(2, abs(ay - by) + 1);
printf("%d\n", 2 * (h + v));
}
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=map(int,raw_input().split())
x2,y2=map(int,raw_input().split())
x=max(abs(x1-x2-1),abs(x1-x2+1))
y=max(abs(y1-y2-1),abs(y1-y2+1))
if x1<>x2 and y1<>y2:
result=2*(x+y)
elif x1<>x2 and y1==y2:
result=4+(2*x)
elif x1==x2 and y1<>y2:
result=4+(2*y)
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>
using namespace std;
int main() {
int x, y, ex, ey;
scanf("%d %d", &x, &y);
scanf("%d %d", &ex, &ey);
int ax, ay;
ax = x - ex;
ay = y - ey;
if (ax < 0) ax *= -1;
if (ay < 0) ay *= -1;
int count = (ax + 1) * 2 + (ay + 1) * 2;
if (ax == 0 || ay == 0) count += 2;
printf("%d",... |
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:256000000")
using namespace std;
int get_dist(int a, int b) { return abs(a - b) ? abs(a - b) + 1 : 2; }
void solve() {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
int ans = get_dist(x1, x2) + get_dist(y1, y2);
printf("%d", ans * 2);
}
int m... |
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... | l1 = input().split()
x1,y1 = int(l1[0]), int(l1[1])
l2 = input().split()
x2,y2 = int(l2[0]), int(l2[1])
w = 0
h = 0
if x1 == x2:
w = 2
else:
w = abs(x1-x2)+1
if y1 == y2:
h = 2
else:
h = abs(y1-y2)+1
print((w+h)*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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class Main
{
static final int mod = (int)1e9+7;
public static void main(String[] args) throws Excepti... |
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;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int a[4];
for (int i = 0; i < 4; ++i) cin >> a[i];
int ans = 2 * (abs(a[2] - a[0]) + abs(a[3] - a[1])) + 4;
if (a[2] == a[0] || a[3] == a[1]) ans += 2;
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
if (x1 == x2) x1++;
if (y1 == y2) y1++;
cout << 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... | x1, y1 = [int(i) for i in input().split()]
x2, y2 = [int(i) for i in input().split()]
minx = min(x1, x2 - 1)
miny = min(y1, y2 - 1)
maxx = max(x1, x2 + 1)
maxy = max(y1, y2 + 1)
print(2 * ((maxx - minx) + (maxy - miny))) |
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, xx, yy, ans, o, p;
int main() {
cin >> x >> y;
cin >> xx >> yy;
o = abs(x - xx) + 1;
p = abs(y - yy) + 1;
ans = o * 2 + 2 * p;
if (x == xx && y == yy)
ans += 5;
else if (x == xx || y == yy)
ans += 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 main() {
int x1, x2, f1, f2;
while (cin >> x1 >> x2 >> f1 >> f2) {
int r = 2 * (abs(f1 - x1) + abs(f2 - x2) + 2);
if (x1 == f1 || x2 == f2) r += 2;
cout << r << 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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long a, b, c, d;
cin >> a >> b >> c >> d;
cout << (max(2LL, abs(c - a) + 1)) * 2 + (max(2LL, abs(d - b) + 1)) * 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... | '''input
1 5
5 2
'''
def readint():
return int(raw_input())
def readints():
return map(int, raw_input().split())
def readstr():
return raw_input()
def readstrs():
return raw_input().split()
def solve():
ans = (abs(x1-x2) + abs(y1-y2) + 2) * 2
if x1 == x2 or y1 == y2: ans += 2
return 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;
long long gcd(long long a, long long b) {
if (b > a) return gcd(b, a);
if (a % b == 0) return b;
return gcd(b, a % b);
}
void sieve() {
int primes[10];
memset(primes, true, sizeof(primes));
primes[0] = false;
primes[1] = false;
for (int i = 2; i <= 10000; 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << (((x2 - x1 > 0 ? x2 - x1 : -(x2 - x1)) > 1
? (x2 - x1 > 0 ? x2 - x1 : -(x2 - x1))
: 1) +
((y2 - y1 > 0 ? y2 - y1 : -(y2 - y1)) > 1
? (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;
template <typename TP>
inline bool rd(TP& r) {
r = 0;
char tmp = getchar();
while (tmp < '0' || tmp > '9') {
if (tmp == EOF) return 0;
tmp = getchar();
}
while ('0' <= tmp && tmp <= '9') {
r = (r << 3) + (r << 1) + tmp - '0';
tmp = getchar();
}
... |
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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) {
Scan sc = new Scan();
out = new PrintWriter(new BufferedOutput... |
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 cf883m {
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 y = (Math.abs(y1-y2));
int x = (Math.abs(x1-x2));
if (x == 0) {
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << (4 + max(abs(x1 - x2), 1) * 2 + max(abs(y1 - y2), 1) * 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... | import java.lang.*;
import java.io.*;
import java.util.*;
import java.math.*;
import java.net.*;
import static java.lang.Math.*;
public class Solution implements Runnable {
void solve() throws Exception {
int x1 = sc.nextInt();
int y1 = sc.nextInt();
int x2 = sc.nextInt();
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << 2 * (max(1, abs(x2 - x1)) + max(1, abs(y2 - y1))) + 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.util.*;
public class quadcopterCompetition
{
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 path=0;
if(((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... | x1,y1=map(int,input().split())
x2,y2=map(int,input().split())
w=2*(abs(x2-x1)+abs(y2-y1)+2)
if x1==x2 or y1==y2 :
print(w+2)
else:
print(w) |
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, y1, x2, y2, l1, l2, p;
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
if (x2 == x1) x2++;
if (y2 == y1) y2++;
x2 += 0 - (x1 - x2) / abs(x1 - x2);
y2 += 0 - (y1 - y2) / abs(y1 - y2);
p = (abs(x1 - x2) + abs(y1 - y2)) * 2;
printf("%d", p);
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... | from sys import exit
xs, ys = map(int, input().split())
xf, yf = map(int, input().split())
if xs == xf:
print((abs(yf - ys) + 1) * 2 + 4)
exit(0)
elif ys == yf:
print((abs(xf - xs) + 1) * 2 + 4)
exit(0)
xs, xf = sorted([xs, xf])
ys, yf = sorted([ys, yf])
xf += 1
yf += 1
print(2 * (xf - xs) + 2 * (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... | first = list(map(int, input().split()))
second = list(map(int, input().split()))
x_len = abs(first[0] - second[0])
y_len = abs(first[1] - second[1])
len_to_point = x_len + y_len
if len_to_point == 1:
print(8)
else:
if x_len == 0 or y_len == 0:
print((len_to_point - 1) *2 + 8)
else:
print((len_to_point -... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.