Submission #905386


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

int N;
int A[1000];

bool solve()
{
    int x=A[0]/2;
    int y=A[0]-x;
    int a=x;
    int b=y;
    int c=1;
    for(int i=0; i<N; i++)
    {
        if(a>0 && a+y==A[i])
            a--;
        else if(b>0 && b+x==A[i])
            b--;
        else if(c>0 && A[i]==min(x, y))
            c--;
        else if(A[i]<min(x, y)+1)
            return false;
    }
    return a==0 && b==0 && c==0;
}

int main()
{
    scanf("%d", &N);
    for(int i=0; i<N; i++)
        scanf("%d", A+i);
    sort(A, A+N, greater<int>());
    if(solve())
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
}

Submission Info

Submission Time
Task C - Tree Restoring
User FatalEagle
Language C++14 (GCC 5.4.1)
Score 0
Code Size 712 Byte
Status WA
Exec Time 3 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:31:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
./Main.cpp:33:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", A+i);
                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 5
WA × 1
AC × 32
WA × 13
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 WA 3 ms 256 KB
almostline1 WA 3 ms 256 KB
almostline2 WA 3 ms 256 KB
almostline3 AC 3 ms 256 KB
can0 AC 3 ms 256 KB
can1 AC 3 ms 256 KB
can2 AC 3 ms 256 KB
can3 AC 3 ms 256 KB
can4 AC 3 ms 256 KB
can5 WA 3 ms 256 KB
can6 WA 3 ms 256 KB
deg0 WA 3 ms 256 KB
deg1 AC 3 ms 256 KB
deg2 WA 3 ms 256 KB
deg3 AC 3 ms 256 KB
example0 WA 3 ms 256 KB
example1 AC 3 ms 256 KB
example2 AC 3 ms 256 KB
example3 AC 3 ms 256 KB
example4 AC 3 ms 256 KB
example5 AC 3 ms 256 KB
handmade0 WA 3 ms 256 KB
line0 WA 3 ms 256 KB
line1 AC 3 ms 256 KB
line2 WA 3 ms 256 KB
line3 AC 3 ms 256 KB
ng10 AC 3 ms 256 KB
ng11 AC 3 ms 256 KB
ng12 AC 3 ms 256 KB
ng13 AC 3 ms 256 KB
ng20 AC 3 ms 256 KB
ng21 AC 3 ms 256 KB
ng22 AC 3 ms 256 KB
ng23 AC 3 ms 256 KB
plus0 AC 3 ms 256 KB
plus1 AC 3 ms 256 KB
plus2 AC 3 ms 256 KB
plus3 AC 3 ms 256 KB
rand0 AC 3 ms 256 KB
rand1 AC 3 ms 256 KB
rand2 AC 3 ms 256 KB
star0 AC 3 ms 256 KB
star1 WA 3 ms 256 KB
star2 AC 3 ms 256 KB
star3 WA 3 ms 256 KB