Submission #1693495


Source Code Expand

#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=500+10;
bool bz[maxn];
int cnt[maxn];
int a[maxn*maxn],wz[maxn*maxn];
int i,j,k,l,t,n,m,tot,top,head;
bool czy;
int main(){
	scanf("%d",&n);
	fo(i,1,n){
		scanf("%d",&t);
		a[t]=i;
	}
	tot=n;
	head=czy=1;
	fd(i,n*n,1){
		if (a[i]){
			bz[a[i]]=1;
			cnt[a[i]]=a[i]-1;
			tot--;
			if (!tot) k=a[i];
		}
		else{
			fo(j,1,n+1)
				if (j<=n&&bz[j]&&cnt[j]){
					cnt[j]--;
					a[i]=j;
					if (tot) wz[++top]=i;
					break;
				}
			if (j>n){
				if (!tot){
					if (head<=top){
						a[i]=a[wz[head]];
						a[wz[head]]=k;
						head++;
					}
					else{
						czy=0;
						break;
					}
				}
				else{
					fo(j,1,n)
						if (!bz[j]){
							a[i]=j;
							break;
						}
				}
			}
		}
	}
	fo(i,1,n)
		if (cnt[i]) czy=0;
	if (!czy) printf("No\n");
	else{
		printf("Yes\n");
		fo(i,1,n*n) printf("%d ",a[i]);
	}
}

Submission Info

Submission Time
Task D - K-th K
User werkeytom
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1024 Byte
Status WA
Exec Time 177 ms
Memory 2560 KB

Compile Error

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
AC × 1
WA × 1
AC × 16
WA × 33
Set Name Test Cases
Sample 0_00.txt, 0_01.txt
All 0_00.txt, 0_01.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt
Case Name Status Exec Time Memory
0_00.txt WA 1 ms 128 KB
0_01.txt AC 1 ms 128 KB
1_00.txt AC 1 ms 128 KB
1_01.txt WA 126 ms 2304 KB
1_02.txt WA 152 ms 2304 KB
1_03.txt WA 140 ms 2304 KB
1_04.txt WA 138 ms 1920 KB
1_05.txt WA 139 ms 2304 KB
1_06.txt WA 155 ms 2304 KB
1_07.txt WA 162 ms 2560 KB
1_08.txt WA 144 ms 1920 KB
1_09.txt AC 128 ms 1152 KB
1_10.txt AC 56 ms 640 KB
1_11.txt AC 135 ms 1536 KB
1_12.txt AC 128 ms 1152 KB
1_13.txt AC 56 ms 640 KB
1_14.txt AC 177 ms 1280 KB
1_15.txt WA 88 ms 1664 KB
1_16.txt AC 121 ms 1536 KB
1_17.txt WA 117 ms 2048 KB
1_18.txt WA 130 ms 2176 KB
1_19.txt WA 134 ms 2176 KB
1_20.txt WA 95 ms 1792 KB
1_21.txt WA 131 ms 2176 KB
1_22.txt WA 110 ms 1920 KB
1_23.txt WA 102 ms 1792 KB
1_24.txt WA 134 ms 2176 KB
1_25.txt WA 92 ms 1664 KB
1_26.txt WA 100 ms 1792 KB
1_27.txt WA 85 ms 1664 KB
1_28.txt AC 118 ms 1536 KB
1_29.txt WA 150 ms 2304 KB
1_30.txt WA 118 ms 2048 KB
1_31.txt WA 135 ms 2304 KB
1_32.txt AC 98 ms 1408 KB
1_33.txt WA 139 ms 2176 KB
1_34.txt AC 125 ms 1536 KB
1_35.txt WA 78 ms 1536 KB
1_36.txt WA 129 ms 2176 KB
1_37.txt WA 117 ms 2048 KB
1_38.txt WA 142 ms 2304 KB
1_39.txt AC 99 ms 1408 KB
1_40.txt WA 40 ms 1024 KB
1_41.txt WA 153 ms 2304 KB
1_42.txt WA 68 ms 1408 KB
1_43.txt WA 124 ms 2048 KB
1_44.txt AC 66 ms 1024 KB
1_45.txt AC 110 ms 1408 KB
1_46.txt AC 120 ms 1536 KB