結果

問題 No.5022 XOR Printer
ユーザー tails
提出日時 2025-07-26 14:43:26
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 1,260 ms
コンパイル使用メモリ 27,512 KB
実行使用メモリ 7,720 KB
スコア 4,796,524,035
最終ジャッジ日時 2025-07-26 14:43:30
合計ジャッジ時間 3,219 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘p’:
main.c:8:9: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
    8 |         puts(&c);
      |         ^~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘puts’
  +++ |+#include <stdio.h>
    1 | int s;
main.c:8:14: warning: passing argument 1 of ‘puts’ from incompatible pointer type [-Wincompatible-pointer-types]
    8 |         puts(&c);
      |              ^~
      |              |
      |              int *
main.c:8:14: note: expected ‘const char *’ but argument is of type ‘int *’
main.c:10:17: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
   10 |                 exit(0);
      |                 ^~~~
main.c:1:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
  +++ |+#include <stdlib.h>
    1 | int s;
main.c:10:17: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
   10 |                 exit(0);
      |                 ^~~~
main.c:10:17: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
main.c: At top level:
main.c:32:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   32 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:33:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
   33 |         scanf("%d",&n);
      |         ^~~~~
main.c:33:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:33:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
main.c:33:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’

ソースコード

diff #

int s;
int t;
int n;
int x,y;
int a[10][10];

void p(int c){
	puts(&c);
	if(--t==0){
		exit(0);
	}
}

void go(int v,int u){
	while(y<v)p('D'),++y;
	while(y>v)p('U'),--y;
	while(x<u)p('R'),++x;
	while(x>u)p('L'),--x;
}

void loc(int q,int *pv,int *pu){
	if(q>=50){
		loc(q-50,pv,pu);
		*pv=9-*pv;
		*pu=9-*pu;
	}else{
		*pv=q/5;
		*pu=q/5%2?q%5:4-q%5;
	}
}

main(){
	scanf("%d",&n);
	scanf("%d",&t);
	for(int v=0;v<10;++v){
		for(int u=0;u<10;++u){
			scanf("%d",&a[v][u]);
		}
	}
	for(int b=20;b--;){
		int lv,lu;
		int v,u;
		for(int q=0;q<100;++q){
			loc(q,&v,&u);
			if((s^a[v][u])>>b==1){
				go(v,u);
				p('C');
				s^=a[v][u];
				break;
			}
		}
		if(s>>b!=1){
			continue;
		}
		for(int q=0;q<100;++q){
			loc(q,&v,&u);
			if(!(a[v][u]>>b&1)){
				go(v,u);
				p('W');
				a[v][u]^=s;
				lv=v;
				lu=u;
			}
		}
		p('W');
		a[lv][lu]^=s;
		p('C');
		s^=a[lv][lu];
	}
}
0