Submission #906368


Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	int a[102];
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	
	int MAX = 0;
	rep(i,n)MAX = max ( MAX , a[i] );
	
	if(MAX == 1){
		if(n == 2)puts("Possible");
		else puts("Impossible");
		return 0;
	}
	
	int cnt[102] = {};
	rep(i,n){
		cnt[a[i]] ++;
	}
	
	for(int i = 1 ; i*2 < MAX ; i ++){
		if(cnt[i] > 0){
			puts("Impossible");
			return 0;
		}
	}
	if(MAX%2 == 0){
		if(cnt[MAX/2] != 1){
			puts("Impossible");
			return 0;
		}
	}
	for(int i = (MAX+2)/2 ; i <= MAX ; i ++){
		if(cnt[MAX] < 2){
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:40:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:41:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  rep(i,n)scanf("%d",&a[i]);
                           ^

Judge Result

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