Submission #906250
Source Code Expand
#include <stdio.h> #include <algorithm> #include <math.h> #include <cstdlib> #include <string.h> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #define SW 1 #define N 110 typedef long long ll; using namespace std; ll n,a[N],ck[N]; bool cmp(ll x,ll y){ return x>y; } void input() { scanf("%lld",&n); ll i; for(i=1;i<=n;i++){ scanf("%lld",&a[i]); } sort(a+1,a+1+n,cmp); } void process() { ll i; if(a[1]!=a[2]){ printf("Impossible"); return; } if(a[1]==1 && n>=3) { printf("Impossible"); return; } // printf("%d ",a[1]); for(i=2;i<=a[1];i++){ ck[max(i-1,a[1]+1-i)]++; } for(i=3;i<=n;i++){ if(ck[a[i]]>0){ ck[a[i]]--; } else{ if(a[i]>=(a[1]+3)/2){ ; } else { printf("Impossible"); return ; } } } for(i=0;i<=n;i++){ if(ck[i]!=0){ printf("Impossible"); return; } } printf("Possible"); } void output() { } int main() { #if SW==0 freopen("input.txt","r",stdin); #endif // SW input(); process(); output(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Tree Restoring |
User | skykhs3 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1370 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 128 KB |
Compile Error
./Main.cpp: In function ‘void input()’: ./Main.cpp:21:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld",&n); ^ ./Main.cpp:24:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld",&a[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
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 | 1 ms | 128 KB |
almostline1 | AC | 1 ms | 128 KB |
almostline2 | AC | 1 ms | 128 KB |
almostline3 | AC | 1 ms | 128 KB |
can0 | AC | 1 ms | 128 KB |
can1 | AC | 1 ms | 128 KB |
can2 | AC | 1 ms | 128 KB |
can3 | AC | 1 ms | 128 KB |
can4 | AC | 1 ms | 128 KB |
can5 | AC | 1 ms | 128 KB |
can6 | AC | 1 ms | 128 KB |
deg0 | AC | 1 ms | 128 KB |
deg1 | AC | 1 ms | 128 KB |
deg2 | AC | 1 ms | 128 KB |
deg3 | AC | 1 ms | 128 KB |
example0 | AC | 1 ms | 128 KB |
example1 | AC | 1 ms | 128 KB |
example2 | AC | 1 ms | 128 KB |
example3 | AC | 1 ms | 128 KB |
example4 | AC | 1 ms | 128 KB |
example5 | AC | 1 ms | 128 KB |
handmade0 | AC | 1 ms | 128 KB |
line0 | AC | 1 ms | 128 KB |
line1 | AC | 1 ms | 128 KB |
line2 | AC | 1 ms | 128 KB |
line3 | AC | 1 ms | 128 KB |
ng10 | AC | 1 ms | 128 KB |
ng11 | AC | 1 ms | 128 KB |
ng12 | AC | 1 ms | 128 KB |
ng13 | AC | 1 ms | 128 KB |
ng20 | AC | 1 ms | 128 KB |
ng21 | AC | 1 ms | 128 KB |
ng22 | AC | 1 ms | 128 KB |
ng23 | AC | 1 ms | 128 KB |
plus0 | AC | 1 ms | 128 KB |
plus1 | AC | 1 ms | 128 KB |
plus2 | AC | 1 ms | 128 KB |
plus3 | AC | 1 ms | 128 KB |
rand0 | AC | 1 ms | 128 KB |
rand1 | AC | 1 ms | 128 KB |
rand2 | AC | 1 ms | 128 KB |
star0 | AC | 1 ms | 128 KB |
star1 | AC | 1 ms | 128 KB |
star2 | AC | 1 ms | 128 KB |
star3 | AC | 1 ms | 128 KB |