Submission #1605046


Source Code Expand

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def solve(c):
    max_length = max(c)
    for i in range(max_length, max_length // 2, -1):
        if c[i] < 2:
            return False

    if max_length % 2 == 0:
        if c[max_length // 2] != 1:
            return False
    else:
        if c[max_length - max_length // 2] != 2:
            return False

    return True


def main():
    N = int(input())
    c = Counter(list(map(int, input().split())))
    print("Possible" if solve(c) else "Impossible")


if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task C - Tree Restoring
User MitI_7
Language Python (3.4.3)
Score 700
Code Size 785 Byte
Status AC
Exec Time 25 ms
Memory 3444 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 6
AC × 45
Set Name Test Cases
Sample example0, example1, example2, example3, example4, example5
All almostline0, almostline1, almostline2, almostline3, can0, can1, can2, can3, can4, can5, can6, deg0, deg1, deg2, deg3, example0, example1, example2, example3, example4, example5, handmade0, line0, line1, line2, line3, ng10, ng11, ng12, ng13, ng20, ng21, ng22, ng23, plus0, plus1, plus2, plus3, rand0, rand1, rand2, star0, star1, star2, star3
Case Name Status Exec Time Memory
almostline0 AC 25 ms 3444 KB
almostline1 AC 20 ms 3316 KB
almostline2 AC 20 ms 3316 KB
almostline3 AC 21 ms 3316 KB
can0 AC 21 ms 3316 KB
can1 AC 21 ms 3316 KB
can2 AC 20 ms 3316 KB
can3 AC 20 ms 3316 KB
can4 AC 21 ms 3316 KB
can5 AC 21 ms 3316 KB
can6 AC 20 ms 3316 KB
deg0 AC 20 ms 3316 KB
deg1 AC 21 ms 3316 KB
deg2 AC 21 ms 3316 KB
deg3 AC 20 ms 3316 KB
example0 AC 21 ms 3316 KB
example1 AC 20 ms 3316 KB
example2 AC 21 ms 3316 KB
example3 AC 21 ms 3316 KB
example4 AC 21 ms 3316 KB
example5 AC 20 ms 3316 KB
handmade0 AC 20 ms 3316 KB
line0 AC 20 ms 3316 KB
line1 AC 20 ms 3316 KB
line2 AC 20 ms 3316 KB
line3 AC 21 ms 3316 KB
ng10 AC 20 ms 3316 KB
ng11 AC 21 ms 3316 KB
ng12 AC 21 ms 3316 KB
ng13 AC 20 ms 3316 KB
ng20 AC 20 ms 3316 KB
ng21 AC 20 ms 3316 KB
ng22 AC 21 ms 3316 KB
ng23 AC 21 ms 3316 KB
plus0 AC 20 ms 3316 KB
plus1 AC 21 ms 3316 KB
plus2 AC 21 ms 3316 KB
plus3 AC 21 ms 3316 KB
rand0 AC 20 ms 3316 KB
rand1 AC 20 ms 3316 KB
rand2 AC 20 ms 3316 KB
star0 AC 20 ms 3316 KB
star1 AC 21 ms 3316 KB
star2 AC 21 ms 3316 KB
star3 AC 20 ms 3316 KB