1642A - Hard Way - CodeForces Solution


geometry *800

Please click on ads to support us..

Python Code:

I =lambda: [*map(int,input().split())]
t,=I()
exec(t*'x,y,z=sorted([I(),I(),I()],key=lambda e:e[1]);print(abs(y[0]-z[0])*(y[1]==z[1]));')

C++ Code:

//K.I.O.
#include <bits/stdc++.h>
//#include "/Users/k.i.o./Downloads/stdc++.h"
using namespace std;
long long n, a, b, c, d, j, t, m, k, u, q, x, y;
using ll = long long;
struct lkio{
    ll x, y;
};
lkio p1, p2, p3;
void F(){
    cin >> p1.x >> p1.y;
    cin >> p2.x >> p2.y;
    cin >> p3.x >> p3.y;
    a = max(p1.y, max(p2.y, p3.y));
    if(a == p1.y && a == p2.y) {
        cout << abs(p1.x - p2.x) << "\n";
        return;
    }
    if(a == p3.y && a == p2.y){
        cout << abs(p3.x - p2.x) << "\n";
        return;
    }
    if(a == p1.y && a == p3.y){
        cout << abs(p1.x - p3.x) << "\n";
        return;
    }
    cout << 0 << "\n";
}
int main(){
    cin >> t;
    while(t--) F();
}


Comments

Submit
0 Comments
More Questions

630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation
550C - Divisibility by Eight
5A - Chat Servers Outgoing Traffic
615A - Bulbs
5B - Center Alignment
549A - Face Detection
535B - Tavas and SaDDas
722C - Destroying Array
366A - Dima and Guards
716B - Complete the Word
1461C - Random Events
1627A - Not Shading
141B - Hopscotch
47B - Coins
1466C - Canine poetry
74A - Room Leader
1333D - Challenges in school №41
1475B - New Year's Number
461A - Appleman and Toastman
320B - Ping-Pong (Easy Version)
948A - Protect Sheep
387A - George and Sleep
53A - Autocomplete
1729G - Cut Substrings
805B - 3-palindrome
805C - Find Amir