Submission #1231022


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int cnt[MAXN];

void solve(){
	int n, a, mx, mn;
	scanf("%d", &n);
	mx = 0;
	mn = INF;
	REP(i, 0, n){
		scanf("%d", &a);
		cnt[a]++;
		mx = max(mx, a);
		mn = min(mn, a);
	}
	if (cnt[mx] == 1){
		printf("Impossible\n");
		return;
	}
	if (mn * 2 < mx || mn * 2 > mx + 1){
		printf("Impossible\n");
		return;
	}
	if (mn * 2 == mx && (cnt[mn] != 1 || cnt[mn + 1] == 1)){
		printf("Impossible\n");
		return;
	}
	if (mn * 2 == mx + 1 && cnt[mn] != 2){
		printf("Impossible\n");
		return;
	}
	for(int i = mx - 1; i > mn; i--){
		if (cnt[i] <= 1){
			printf("Impossible\n");
			return;
		}
	}
	printf("Possible\n");
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Submission Info

Submission Time
Task C - Tree Restoring
User Timur_Sitdikov
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1658 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

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

Judge Result

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