AtCoder Grand Contest 005

Submission #1585941

Source codeソースコード

#include<iostream>
#include<cstdio>
#include<cstring>
namespace OoO
{
	const int N=105;
	int c[N];
	int n,L;
	bool check()
	{
		if(L==1 && n>2)return 0;
		if(n==1)return 0;
		if(c[L]==1)return 0;

		c[L]=0;
		int hl=L/2;
		for(int i=L-1;i>hl;i--)
			if(c[i]<2)return 0;
			else c[i]-=2;
		if(L%2==0){if(!c[hl])return 0;c[hl]--;}
		for(int i=1;i<=hl+(L%2);i++)
			if(c[i])return 0;
		return 1;
	}
	void solve()
	{
		scanf("%d",&n);
		for(int i=1,x;i<=n;i++)
			scanf("%d",&x),c[x]++;
		for(int i=n;i;i--)if(c[i]){L=i;break;}
		printf("%s\n",check()?"Possible":"Impossible");
	}
}
int main()
{
	OoO::solve();
	return 0;
}

Submission

Task問題 C - Tree Restoring
User nameユーザ名 Demerzel_IV
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 700
Source lengthソースコード長 658 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 256 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘void OoO::solve()’:
./Main.cpp:27:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:29:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x),c[x]++;
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0,example1,example2,example3,example4,example5
All 700 / 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
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