Submission #1301124
Source Code Expand
n = input() D = [tuple(map(int, raw_input().split())) for i in xrange(n)] if (not D[0][0] == D[1][1] == 0 or not D[0][1] == D[1][0] > 0 or any(i>1 and (d[0] == 0 or d[1] == 0) for i, d in enumerate(D))): print -1 exit(0) m = {} for i, d in enumerate(D): m[d] = m.get(d, 0) + 1 if i>0 else 0 D.sort() used = [0]*n cnt = 0 for x, y in D: if (x+1, y+1) in m: cnt += m[x+1, y+1] m[x+1, y+1] = 0 if (x+1, y-1) in m: cnt += m[x+1, y-1] m[x+1, y-1] = 0 ok = 1 for x, y in D: if m[x, y] > 0: if (x-1, y) not in m or (x, y-1) not in m: ok = 0 if ok: print 2*n - 2 - cnt else: print -1
Submission Info
Submission Time | |
---|---|
Task | A - Distance Pairs |
User | yaketake08 |
Language | Python (2.7.6) |
Score | 0 |
Code Size | 696 Byte |
Status | WA |
Exec Time | 524 ms |
Memory | 24508 KB |
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
All | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 482 ms | 24508 KB |
01-02.txt | AC | 429 ms | 11332 KB |
01-03.txt | AC | 10 ms | 2696 KB |
01-04.txt | AC | 10 ms | 2696 KB |
01-05.txt | AC | 14 ms | 2696 KB |
01-06.txt | WA | 245 ms | 7724 KB |
01-07.txt | WA | 434 ms | 11580 KB |
01-08.txt | WA | 457 ms | 11584 KB |
01-09.txt | WA | 466 ms | 11452 KB |
01-10.txt | WA | 424 ms | 11328 KB |
01-11.txt | AC | 423 ms | 12224 KB |
01-12.txt | AC | 407 ms | 11868 KB |
01-13.txt | AC | 509 ms | 24508 KB |
01-14.txt | AC | 499 ms | 24508 KB |
01-15.txt | AC | 500 ms | 24508 KB |
01-16.txt | AC | 319 ms | 11404 KB |
01-17.txt | WA | 360 ms | 11404 KB |
01-18.txt | AC | 365 ms | 11404 KB |
01-19.txt | WA | 489 ms | 24508 KB |
01-20.txt | WA | 503 ms | 19008 KB |
01-21.txt | WA | 524 ms | 19516 KB |
01-22.txt | WA | 491 ms | 19388 KB |
01-23.txt | AC | 454 ms | 13632 KB |
01-24.txt | AC | 471 ms | 11584 KB |
01-25.txt | AC | 244 ms | 10636 KB |
01-26.txt | AC | 252 ms | 10636 KB |
01-27.txt | AC | 238 ms | 10636 KB |
01-28.txt | AC | 246 ms | 10636 KB |
01-29.txt | AC | 10 ms | 2696 KB |
01-30.txt | AC | 10 ms | 2696 KB |
01-31.txt | AC | 10 ms | 2696 KB |
sample-01.txt | AC | 10 ms | 2696 KB |
sample-02.txt | AC | 10 ms | 2696 KB |