CODE FESTIVAL 2016 Exhibition

Submission #1301124

Source codeソースコード

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

Task問題 A - Distance Pairs
User nameユーザ名 tjake
Created time投稿日時
Language言語 Python2 (2.7.6)
Status状態 WA
Score得点 0
Source lengthソースコード長 696 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
All 0 / 1500 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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
01-07.txt WA
01-08.txt WA
01-09.txt WA
01-10.txt WA
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
01-18.txt AC 365 ms 11404 KB
01-19.txt WA
01-20.txt WA
01-21.txt WA
01-22.txt WA
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