QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197559#3525. Move & MeetIsaacMoris#WA 0ms3628kbC++141.4kb2023-10-02 17:06:192023-10-02 17:06:20

Judging History

This is the latest submission verdict.

  • [2023-10-02 17:06:20]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3628kb
  • [2023-10-02 17:06:19]
  • Submitted

answer

#include<iostream>
#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 3e5 + 5, inf = 2e9;


void doWork() {
    ll x1, y1, x2, y2, d1, d2;
    cin >> x1 >> y1 >> d1;
    cin >> x2 >> y2 >> d2;
    if (d1 > d2) {
        swap(x1, y1);
        swap(x2, y2);
        swap(d1, d2);
    }
    ll d3 = abs(x1 - x2) + abs(y1 - y2);
    //cout << d3 << "\n";
    if (d3 <= d1 + d2 && (d1 + d2 - d3) % 2 == 0) {
        ll mx = x1, my = y1;

        if (x2 > x1) mx += min(x2 - x1, d1);
        else mx -= min(x1 - x2, d1);

        if (y2 > y1)my += min(y2 - y1, d1 - min(abs(x2 - x1), d1));
        else my -= min(y1 - y2, d1 - min(abs(x2 - x1), d1));

        for (ll i = mx - 3; i <= mx + 3; i++) {
            for (ll j = my - 3; j <= my + 3; j++) {
                ll a = abs(x1 - i) + abs(y1 - j), b = abs(x2 - i) + abs(y2 - j);
                if (a <= d1 && b <= d2 && (d1 - a) % 2 == 0 && (d2 - b) % 2 == 0) {
                    cout << i << " " << j;
                    return;
                }
            }
        }
        cout << "impossible\n";
    } else {
        cout << "impossible\n";
    }
}

int main() {
    IO
    int t = 1;
    //   cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

-1 -2 0
1 2 6

output:

-1 -2

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

1 -2 5
-3 3 8

output:

-4 -2

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

0 -1000000000000 0
0 -1000000000000 0

output:

0 -1000000000000

result:

ok 

Test #4:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

-5 -426 932111
83 -870 478692

output:

impossible

result:

ok 

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3628kb

input:

4 5 6
4 -2 1

output:

4 4

result:

wrong answer WA: bad coordinates