QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#70778#3525. Move & MeetjuwkimWA 18ms8288kbPython3707b2023-01-07 22:40:152023-01-09 01:26:00

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-09 01:26:00]
  • Judged
  • Verdict: WA
  • Time: 18ms
  • Memory: 8288kb
  • [2023-01-07 22:40:15]
  • Submitted

answer

def solve():

    x1, y1, d1 = map(int, input().split())
    x2, y2, d2 = map(int, input().split())

    dist = abs(x1 - x2) + abs(y1 - y2)

    if dist > d1 + d2:
        return 'impossible'
    
    def move(p, q, d):
        dmove = min(abs(p - q), d)
        return p + [-dmove, dmove][q > p], d - dmove

    x2, d2 = move(x2, x1, d2)
    y2, d2 = move(y2, y1, d2)
    
    x1, d1 = move(x1, x2, d1)
    y1, d1 = move(y1, y2, d1)
    
    
    assert (x1, y1) == (x2, y2), "Invalid result"
    
    r1, r2 = d1 & 1, d2 & 1
    if r1 != r2:
        return 'impossible'
    return x1 + r1, y1 + r1

ans = solve()
if ans == 'impossible':
    print(ans)
else:
    print(*ans)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 8152kb

input:

-1 -2 0
1 2 6

output:

-1 -2

result:

ok 

Test #2:

score: 0
Accepted
time: 10ms
memory: 8184kb

input:

1 -2 5
-3 3 8

output:

1 -1

result:

ok 

Test #3:

score: 0
Accepted
time: 3ms
memory: 8284kb

input:

0 -1000000000000 0
0 -1000000000000 0

output:

0 -1000000000000

result:

ok 

Test #4:

score: 0
Accepted
time: 4ms
memory: 8216kb

input:

-5 -426 932111
83 -870 478692

output:

impossible

result:

ok 

Test #5:

score: 0
Accepted
time: 6ms
memory: 8288kb

input:

4 5 6
4 -2 1

output:

4 -1

result:

ok 

Test #6:

score: 0
Accepted
time: 8ms
memory: 8116kb

input:

0 0 2
2 2 2

output:

0 2

result:

ok 

Test #7:

score: 0
Accepted
time: 9ms
memory: 8112kb

input:

0 0 1000000000000
5 19923 186

output:

0 19742

result:

ok 

Test #8:

score: 0
Accepted
time: 7ms
memory: 8152kb

input:

-237700907237 445576550446 594610055595
681973265681 -171560526172 843757392844

output:

impossible

result:

ok 

Test #9:

score: 0
Accepted
time: 14ms
memory: 8180kb

input:

-537351556538 -807721987807 690465417691
287415372288 977794499977 17905823179

output:

impossible

result:

ok 

Test #10:

score: 0
Accepted
time: 8ms
memory: 8160kb

input:

30 40 100000
-120 1 100

output:

impossible

result:

ok 

Test #11:

score: 0
Accepted
time: 11ms
memory: 8212kb

input:

267127854709 343405973674 26161892148
381294549365 370274347369 145141827064

output:

impossible

result:

ok 

Test #12:

score: 0
Accepted
time: 18ms
memory: 8064kb

input:

-31878165543 682414817093 568347503685
70100797810 257224740065 112811330402

output:

-31878165543 268057107114

result:

ok 

Test #13:

score: 0
Accepted
time: 5ms
memory: 8228kb

input:

387193259973 268407387361 274058113004
486675093266 437040007372 635497639980

output:

387193259973 268407387361

result:

ok 

Test #14:

score: 0
Accepted
time: 7ms
memory: 8156kb

input:

-66320811801 919108842699 157508694485
-80000538110 914988414819 82749433617

output:

impossible

result:

ok 

Test #15:

score: 0
Accepted
time: 7ms
memory: 8188kb

input:

765386284887 767515994322 844612298930
-497093441686 743109429921 768922899446

output:

271829457760 743109429921

result:

ok 

Test #16:

score: 0
Accepted
time: 13ms
memory: 8060kb

input:

576684618279 101148508605 965690689741
223791260345 -615434796187 201910224082

output:

impossible

result:

ok 

Test #17:

score: 0
Accepted
time: 10ms
memory: 8216kb

input:

607440915555 -437703752649 654737937086
917936905179 -135927848060 807123864242

output:

impossible

result:

ok 

Test #18:

score: -100
Wrong Answer
time: 11ms
memory: 8164kb

input:

549382762652 -122436732168 729685198193
705070160054 -280825314671 720490842890

output:

549382762653 -122436732167

result:

wrong answer WA: bad coordinates