結果

問題 No.459 C-VS for yukicoder
ユーザー YamyukiYamyuki
提出日時 2016-12-10 22:42:26
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,721 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 27,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 10:37:57
合計ジャッジ時間 5,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 5 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 WA -
testcase_32 AC 1 ms
4,376 KB
testcase_33 WA -
testcase_34 AC 6 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 5 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 WA -
testcase_39 AC 2 ms
4,376 KB
testcase_40 WA -
testcase_41 AC 1 ms
4,376 KB
testcase_42 WA -
testcase_43 AC 5 ms
4,376 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 2 ms
4,380 KB
testcase_47 WA -
testcase_48 AC 5 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 2 ms
4,380 KB
testcase_54 WA -
testcase_55 AC 2 ms
4,376 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 5 ms
4,384 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘print’:
main.c:23:2: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
  memcpy(copy,c,sizeof(c));
  ^~~~~~
main.c:23:2: warning: incompatible implicit declaration of built-in function ‘memcpy’
main.c:23:2: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
main.c:3:1:
+#include <string.h>
 
main.c:23:2:
  memcpy(copy,c,sizeof(c));
  ^~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int w,n,result[10000],border[10000],check[10000];

typedef struct{
	int ans[3];
	int order;
	int id;
} block;

block c[30000];

int cmp(const void*,const void*);
int cmp_id(const void*,const void*);
int sum(block a){
	return a.ans[0]+a.ans[1]+a.ans[2];
}

void print(){
	block copy[30000];
	int i,j;
	memcpy(copy,c,sizeof(c));
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			if(copy[i].ans[0]>=3-j) printf("#");
			else printf(".");
			if(copy[i].ans[1]>=3-j) printf("#");
			else printf(".");
			if(copy[i].ans[2]>=3-j) printf("#");
			else printf(".");
			printf("\n");
		}
	}
	printf("--\n");
}

int main(){
	int h,i,j,now,lj;
	char s;
	scanf("%d %d %d",&h,&w,&n);
	getchar();
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			scanf("%c",&s);
			if(s=='#'){
				result[j]++;
			}
		}
		getchar();
	}
	for(i=0;i<n;i++){
		scanf("%d",&c[i].order);
		c[i].id=i;
		c[i].ans[0]=1;
		check[c[i].order]++;
	}
	qsort(c,n,sizeof(block),cmp);
	i=0;
	j=0;
	lj=0;
	while(i<w-2){
		if(j>=n){
			for(;i<w-2;i++){
				border[i]=lj;
			}
		}else if(c[j].order!=i){
			border[i]=j;
			lj=j;
			i++;
		}else{
			j++;
		}
	}
	for(i=0;i<w;i++){
		//printf("%d\n",i);
		if(result[i]>check[i]){
			if(i>2){
			now=border[i-3];
			}else{
				now=0;
			}
			while(check[i]<result[i]){
				if(result[i]-check[i]>2){
					c[now].ans[i-c[now].order]+=(j=3-c[now].ans[i-c[now].order]);
				}else{
					j=3-c[now].ans[i-c[now].order];
					c[now].ans[i-c[now].order]+=(j=(j>result[i]-check[i])?result[i]-check[i]:j);
				}
				check[i]+=j;
				now++;
			}
		}else if(result[i]<check[i]){
			//printf("%d\n",i);
			if(i>1){
				now=border[i-2];
			}else{
				now=0;
			}
			for(j=now;j<border[i];j++){
				if(sum(c[j])>1){
					c[j].ans[i-c[j].order]--;
					check[i]--;
					if(check[i]==result[i]) break;
				}
			}
			if(check[i]>result[i]){
				for(j=border[i]-1;result[i]<check[i];j--){
					c[j].ans[i-c[j].order]--;
					check[i]--;
					c[j].ans[i-c[j].order+1]++;
					check[i+1]++;
				}
			}
		}
		/*
		while(result[i]>0){
			if(now<n && c[now].order<=i){
				if(c[now].ans[i-c[now].order]<3){
					c[now].ans[i-c[now].order]++;
					result[i]--;
				}
				now++;
			}else{
				if(i>2){
					now=border[i-3];
				}else{
					now=0;
				}
			}
		}
		*/
	}
	qsort(c,n,sizeof(block),cmp_id);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			if(c[i].ans[0]>=3-j) printf("#");
			else printf(".");
			if(c[i].ans[1]>=3-j) printf("#");
			else printf(".");
			if(c[i].ans[2]>=3-j) printf("#");
			else printf(".");
			printf("\n");
		}
	}
	return 0;
}

int cmp(const void* a,const void* b){
	return ((block *)a)->order-((block *)b)->order;
}

int cmp_id(const void *a,const void *b){
	return ((block*)a)->id-((block*)b)->id;
}
0