Submission #1595211


Source Code Expand

#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const LL INF=LONG_MAX;
const double EPS=0.00001;
const long double PI = acos(-1.0);

const int MAX_N=2e5+2;

int cnt[101];
int main(){
    int N;
    cin>>N;
    CLR(cnt);
    vector<int>aa;
    REP(i,N){
        int a;
        cin>>a;
        aa.PB(a);
        cnt[a]++;
    }
    SORT(aa);
    REP(i,SZ(aa)-1)if(aa[i+1]-aa[i]>1){
        cout<<"Impossible"<<endl;
        return 0;
    }

    if(cnt[1]>0){
        if((cnt[1]==1&&cnt[1]+cnt[2]==N)||(cnt[1]==2&&N==2)){
            cout<<"Possible"<<endl;
        }else{
            cout<<"Impossible"<<endl;
        }
        return 0;
    }else{
        int cnt1=0;
        REP(i,N)if(cnt[i]==1){
            cnt1++;
        }
        if(cnt1>=2){
            cout<<"Impossible"<<endl;
        }else{
            cout<<"Possible"<<endl;
        }
        return 0;
    }

    return 0;
}

Submission Info

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 6
AC × 42
WA × 3
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 1 ms 256 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 WA 1 ms 256 KB
ng11 WA 1 ms 256 KB
ng12 WA 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