Submission #1799807
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 1987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#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; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서
int cnt[100];
int main() {
int n;
scanf("%d", &n);
fup(i, 1, n, 1)
{
int x;
scanf("%d", &x);
cnt[x]++;
}
if (cnt[1] == 1)
{
fup(i,3,n-1,1)
if (cnt[i])
{
puts("Impossible");
return 0;
}
}
if (cnt[1] == 2)
{
fup(i, 2, n-1, 1)
if (cnt[i])
{
puts("Impossible");
return 0;
}
}
if(cnt[1]>=3)
{
puts("Impossible");
return 0;
}
int sum = 0;
fup(i, (n + 1) / 2, n - 1, 1)
{
sum += cnt[i];
if(cnt[i]==1)
{
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 |
1868 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:48: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 |
|
|
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 |
WA |
1 ms |
256 KB |
ng21 |
WA |
1 ms |
256 KB |
ng22 |
WA |
1 ms |
256 KB |
ng23 |
WA |
1 ms |
256 KB |
plus0 |
AC |
1 ms |
256 KB |
plus1 |
WA |
1 ms |
256 KB |
plus2 |
WA |
1 ms |
256 KB |
plus3 |
WA |
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 |