Submission #1440380
Source Code Expand
// This amazing code is by Eric Sunli Chen. #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <cstdio> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; template<typename T> void get_int(T &x) { char t=getchar(); bool neg=false; x=0; for(; (t>'9'||t<'0')&&t!='-'; t=getchar()); if(t=='-')neg=true,t=getchar(); for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0'; if(neg)x=-x; } template<typename T> void print_int(T x) { if(x<0)putchar('-'),x=-x; short a[20]= {},sz=0; while(x>0)a[sz++]=x%10,x/=10; if(sz==0)putchar('0'); for(int i=sz-1; i>=0; i--)putchar('0'+a[i]); } #define ff first #define ss second #define pb push_back #define mp make_pair #define get1(a) get_int(a) #define get2(a,b) get1(a),get1(b) #define get3(a,b,c) get1(a),get2(b,c) #define printendl(a) print_int(a),puts("") typedef long long LL; typedef unsigned long long uLL; typedef pair<int,int> pii; const int inf=0x3f3f3f3f; const LL Linf=1ll<<61; const double pi=acos(-1.0); int cnt[111],n,mx; void nosol(){puts("Impossible");exit(0);} int main() { get1(n); for(int i=1,x;i<=n;i++) { get1(x); cnt[x]++; mx=max(mx,x); } for(int i=mx;i>mx/2;i--) { if(cnt[i]<2)nosol(); cnt[i]-=2; } if(mx%2==0) { if(cnt[mx/2]<1)nosol(); cnt[mx/2]-=1; } int mx2=(mx+1)/2+1; for(int i=0;i<mx2;i++)if(cnt[i])nosol(); puts("Possible"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Tree Restoring |
User | OhWeOnFire |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1594 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 384 KB |
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 | 256 KB |
almostline1 | AC | 1 ms | 256 KB |
almostline2 | AC | 1 ms | 256 KB |
almostline3 | AC | 1 ms | 256 KB |
can0 | AC | 1 ms | 256 KB |
can1 | AC | 1 ms | 256 KB |
can2 | AC | 1 ms | 256 KB |
can3 | AC | 1 ms | 256 KB |
can4 | AC | 1 ms | 256 KB |
can5 | AC | 1 ms | 256 KB |
can6 | AC | 1 ms | 256 KB |
deg0 | AC | 1 ms | 256 KB |
deg1 | AC | 1 ms | 256 KB |
deg2 | AC | 1 ms | 256 KB |
deg3 | AC | 2 ms | 384 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
example3 | AC | 1 ms | 256 KB |
example4 | AC | 1 ms | 256 KB |
example5 | AC | 1 ms | 256 KB |
handmade0 | AC | 1 ms | 256 KB |
line0 | AC | 1 ms | 256 KB |
line1 | AC | 1 ms | 256 KB |
line2 | AC | 1 ms | 256 KB |
line3 | AC | 1 ms | 256 KB |
ng10 | AC | 1 ms | 256 KB |
ng11 | AC | 1 ms | 256 KB |
ng12 | AC | 1 ms | 256 KB |
ng13 | AC | 1 ms | 256 KB |
ng20 | AC | 1 ms | 256 KB |
ng21 | AC | 1 ms | 256 KB |
ng22 | AC | 1 ms | 256 KB |
ng23 | AC | 1 ms | 256 KB |
plus0 | AC | 1 ms | 256 KB |
plus1 | AC | 1 ms | 256 KB |
plus2 | AC | 1 ms | 256 KB |
plus3 | AC | 1 ms | 256 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | AC | 1 ms | 256 KB |
star0 | AC | 1 ms | 256 KB |
star1 | AC | 1 ms | 256 KB |
star2 | AC | 1 ms | 256 KB |
star3 | AC | 1 ms | 256 KB |