結果

問題 No.142 単なる配列の操作に関する実装問題
コンテスト
ユーザー fumofumofuni
提出日時 2022-08-09 00:53:21
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,068 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 28,292 KB
最終ジャッジ日時 2026-02-22 09:24:41
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:2:1: warning: data definition has no type or storage class
    2 | n,p,s,x,y,z,i,j;
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
main.c:2:3: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |   ^
main.c:2:5: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |     ^
main.c:2:7: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |       ^
main.c:2:9: error: type defaults to 'int' in declaration of 'y' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |         ^
main.c:2:11: error: type defaults to 'int' in declaration of 'z' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |           ^
main.c:2:13: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |             ^
main.c:2:15: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    2 | n,p,s,x,y,z,i,j;
      |               ^
main.c: In function 'main':
main.c:6:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    6 |         scanf("%d%d%d%d%d%*d",&n,&s,&x,&y,&z);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | unsigned long a[32000],temp[1600];
main.c:6:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    6 |         scanf("%d%d%d%d%d%*d",&n,&s,&x,&y,&z);
      |         ^~~~~
main.c:6:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:44:26: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration]
   44 |         for(i=1;i<=n;i++)putchar((a[i>>6]>>(i&63))&1?'O':'E');
      |                          ^~~~~~~
main.c:44:26: note: include '<stdio.h>' or provide a declaration of 'putchar'

ソースコード

diff #
raw source code

unsigned long a[32000],temp[1600];
n,p,s,x,y,z,i,j;
long t;

int main(){
	scanf("%d%d%d%d%d%*d",&n,&s,&x,&y,&z);

	//初期値の設定
	a[0]=s&1<<1;
	t=s;
	for(i=2;i<=n;i++){
		t=(t*x+y)%z;
		a[i>>6]|=(t&1)<<(i&63);
	}
	//a[i]のjbit目が問題文中のA[i*64+j]の偶奇に対応する
	//Aは1-basedであることに注意

	for(;~scanf("%d%d%d%*d",&s,&x,&y);){
		x-=s-1;
		//書き換える要素の個数
		
		//加算元をtempに持ってくる処理
		p=s&63;
		z=64-p;
		for(i=0,j=s>>6;i<<6<x;i++,j++){
			//A[S](S=j*64+p)からの偶奇をtemp[0]の0bit目から順に保存していく
			temp[i]=a[j]>>p;
			if(p)temp[i]|=a[j+1]<<z;
		}
		z=64-(x&63);
		if(z!=64)temp[i-1]=temp[i-1]<<z>>z;
		//tempにはceil(x/64)*64個分の値が保存されたので
		//はみ出した部分はshiftによるオーバーフローで消す
		
		//tempを指定位置に加算する処理
		p=y&63;
		z=64-p;
		for(i=0,j=y>>6;i<<6<x;i++,j++){
			a[j]^=temp[i]<<p;
			if(p)a[j+1]^=temp[i]>>z;
		}
	}

	for(i=1;i<=n;i++)putchar((a[i>>6]>>(i&63))&1?'O':'E');
	return 0;
}
0