結果
| 問題 |
No.459 C-VS for yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-11 09:55:54 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,161 bytes |
| コンパイル時間 | 154 ms |
| コンパイル使用メモリ | 23,168 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-29 03:08:45 |
| 合計ジャッジ時間 | 4,378 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 WA * 13 |
コンパイルメッセージ
main.c: In function ‘print’:
main.c:21:9: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
21 | memcpy(copy,c,sizeof(c));
| ^~~~~~
main.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
2 | #include<stdlib.h>
+++ |+#include <string.h>
3 |
main.c:21:9: warning: incompatible implicit declaration of built-in function ‘memcpy’ [-Wbuiltin-declaration-mismatch]
21 | memcpy(copy,c,sizeof(c));
| ^~~~~~
main.c:21:9: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’
main.c: In function ‘main’:
main.c:39:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d %d %d",&h,&w,&n);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:43:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | scanf("%c",&s);
| ^~~~~~~~~~~~~~
main.c:51:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
51 | scanf("%d",&c[i].order);
| ^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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*);
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;
for(j=0;j<3;j++){
if(result[c[i].order+j]>check[c[i].order+j]){
c[i].ans[j]=1;
check[c[i].order+j]++;
break;
}
}
}
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++;
}
}
border[w-2]=n;
border[w-1]=n;*/
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;
}*/
now=0;
while(check[i]<result[i]){
if(i-c[now].order>=0 && i-c[now].order<3){
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++;
}
}
}
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;
}