Submission #1820422


Source Code Expand

#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 1987654321987654321
#define PI 3.14159265358979323846264
#define MOD 20091101
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서

int n, cnt[100];
int main() {
	scanf("%d", &n);
	int K = 0;
	fup(i, 0, n - 1, 1)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
		K = max(K, x);
	}
	if (K & 1)
	{
		fup(i, K / 2 + 1, K, 1)
		{
			cnt[i] -= 2;
			if (cnt[i] < 0)
			{
				puts("Impossible");
				return 0;
			}
		}
		fup(i,1,K/2,1)
			if(cnt[i])
			{
				puts("Impossible");
				return 0;
			}
	}
	else
	{
		cnt[K / 2]++;
		fup(i, K / 2, K, 1)
		{
			cnt[i] -= 2;
			if (cnt[i] < 0)
			{
				puts("Impossible");
				return 0;
			}
		}
		fup(i, 1, K / 2 - 1, 1)
			if (cnt[i])
			{
				puts("Impossible");
				return 0;
			}
	}
	puts("Possible");
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:47:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:52:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 5
WA × 1
AC × 40
WA × 5
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 WA 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 WA 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