Submission #905108


Source Code Expand

#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#include<iostream>
#include<ctype.h>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<bitset>
#include<iomanip>
#include<complex>
#include<utility>

#define X first
#define Y second
#define REP_0(i,n) for(int i=0;i<(n);++i)
#define REP_1(i,n) for(int i=1;i<=(n);++i)
#define REP_2(i,a,b) for(int i=(a);i<(b);++i)
#define REP_3(i,a,b) for(int i=(a);i<=(b);++i)
#define REP_4(i,a,b,c) for(int i=(a);i<(b);i+=(c))
#define DOW_0(i,n) for(int i=(n)-1;-1<i;--i)
#define DOW_1(i,n) for(int i=(n);0<i;--i)
#define DOW_2(i,a,b) for(int i=(b);(a)<i;--i)
#define DOW_3(i,a,b) for(int i=(b);(a)<=i;--i)
#define FOREACH(a,b) for(typeof((b).begin()) a=(b).begin();a!=(b).end();++a)
#define RFOREACH(a,b) for(typeof((b).rbegin()) a=(b).rbegin();a!=(b).rend();++a)
#define PB push_back
#define PF push_front
#define MP make_pair
#define IS insert
#define ES erase
#define IT iterator
#define RI reserve_iterator
#define PQ priority_queue
#define LB lower_bound
#define UB upper_bound
#define ALL(x) x.begin(),x.end()

#define PI 3.1415926535897932384626433832795
#define EXP 2.7182818284590452353602874713527

using namespace std;

typedef long long LL;
typedef long double LD;
typedef double DB;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef pair<int,PII> PIII;
typedef pair<LD,int> PLDI;
typedef vector<PII> VII;

template<class T>
T Mul(T x,T y,T P){
	T F1=0;
	while(y)
	{
		if(y&1)
		{
			F1+=x;
			if(F1<0||F1>=P)F1-=P;
		}
		x<<=1;
		if(x<0||x>=P)x-=P;
		y>>=1;
	}
	return F1;
}

template<class T>
T Pow(T x,T y,T P){
	T F1=1;x%=P;
	while(y)
	{
		if(y&1)
		{
			F1=Mul(F1,x,P);
		}
		x=Mul(x,x,P);
		y>>=1;
	}
	return F1;
}

template<class T>
T Gcd(T x,T y){
	if(y==0)return x;
	T z;
	while(z=x%y){
		x=y,y=z;
	}
	return y;
}

template<class T>
void UpdateMin(T &x,T y){
	if(y<x)
	{
		x=y;
	}
}

template<class T>
void UpdateMax(T &x,T y){
	if(x<y)
	{
		x=y;
	}
}

template<class T>
T Sqr(const T x){
	return x*x;
}

template<class T>
T Abs(const T x){
	return x<0?-x:x;
}

#define MaxBuffer 20000000
class ReadBuffer{
	private:
	char buff[MaxBuffer];
	char *buf;
	public:
	void init(int size=MaxBuffer)
	{
		fread(buff,1,size,stdin);
		buf=buff;
	}
	template<class T>
	bool readInteger(T &x)
	{
		x=0;
		while(*buf&&isspace(*buf)) ++buf;
		if(*buf==0) return false;
		static bool flag;
		flag=0;
		if(*buf=='-') flag=true;
		else x=*buf-'0';
		while(isdigit(*++buf)) x=x*10+*buf-'0';
		if(flag) x=-x;
		return true;
	}
	template<class T>
	bool readFloat(T &x)
	{
		long double nowpos=0.1;
		x=0;
		while(*buf&&isspace(*buf)) ++buf;
		if(*buf==0) return false;
		static bool flag,decimal;
		decimal=flag=0;
		if(*buf=='-') flag=true,++buf;
		else if(*buf=='.') decimal=true;
		while(isdigit(*buf)||*buf=='.')
		{
			if(*buf=='.') decimal=true;
			else
			{
				if(decimal)
				{
					x+=nowpos*(*buf-'0');
					nowpos*=0.1;
				}
				else
				{
					x=x*10+*buf-'0';
				}
			}
			++buf;
		}
		return true;
	}
	bool readChar(char c)
	{
		if(*buf==0) return 0;
		return c=*buf++,1;
	}
	bool readString(char *s)
	{
		while(*buf&&isspace(*buf)) ++buf;
		if(!*buf) return false;
		while(!isspace(*buf)) *s++=*buf++;
		*s++=0;
		return true;
	}
	int countSpacetonext(){
		int total=0;
		while(*buf&&*buf==' ') ++total,++buf;
		return total;
	}
	bool splitBycharactor(char *s,char Split='\n'){
		while(*buf&&*buf!=Split) *s++=*buf++;
		*s++=0;
		return *buf!=0;
	}
};

struct EDGE{
	int T;EDGE *Nxt;
};

int A[101];
int N;

bitset<101> B;

int MD=0;

int cnt[101];

int main(){
	scanf("%d",&N);
	REP_1(i,N){
		scanf("%d",A+i);
		MD=max(A[i],MD);
		++cnt[A[i]];
	}
	if(N==2){
		printf("Possible\n");
	}
	else{
		if(MD==1){
			printf("Impossible\n");
			return 0;
		}
		if(MD%2==0){
			if(cnt[MD/2]!=1){
				printf("Impossible\n");
				return 0;
			}
		}
		for(int i=1;2*i<MD;++i){
			if(cnt[i]){
				printf("Impossible\n");
				return 0;
			}
		}
		for(int i=MD/2+1;i<=MD;++i){
			if(cnt[i]<2){
				printf("Impossible\n");
				return 0;
			}
		}
		printf("Possible\n");
	}
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:220:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&N);
                ^
./Main.cpp:222:18: 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 × 6
AC × 43
WA × 2
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 3 ms 256 KB
almostline1 AC 3 ms 256 KB
almostline2 AC 3 ms 384 KB
almostline3 AC 3 ms 256 KB
can0 AC 2 ms 256 KB
can1 AC 3 ms 256 KB
can2 AC 2 ms 256 KB
can3 AC 3 ms 256 KB
can4 AC 3 ms 256 KB
can5 AC 3 ms 256 KB
can6 AC 3 ms 256 KB
deg0 AC 3 ms 256 KB
deg1 AC 3 ms 256 KB
deg2 AC 3 ms 384 KB
deg3 AC 3 ms 256 KB
example0 AC 3 ms 256 KB
example1 AC 3 ms 256 KB
example2 AC 2 ms 256 KB
example3 AC 3 ms 256 KB
example4 AC 3 ms 256 KB
example5 AC 3 ms 256 KB
handmade0 AC 2 ms 256 KB
line0 AC 3 ms 256 KB
line1 AC 3 ms 256 KB
line2 AC 3 ms 256 KB
line3 AC 3 ms 256 KB
ng10 WA 3 ms 256 KB
ng11 AC 3 ms 256 KB
ng12 WA 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 2 ms 256 KB
plus0 AC 3 ms 256 KB
plus1 AC 3 ms 384 KB
plus2 AC 3 ms 256 KB
plus3 AC 2 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 AC 3 ms 384 KB
star2 AC 3 ms 256 KB
star3 AC 3 ms 384 KB