結果

問題 No.942 プレゼント配り
ユーザー tailstails
提出日時 2020-11-24 17:47:29
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 31,432 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 01:07:13
合計ジャッジ時間 2,260 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:6:9: 警告: initialization of ‘char *’ from incompatible pointer type ‘long int *’ [-Wincompatible-pointer-types]
    6 | char*rp=buf;
      |         ^~~
main.c:12:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   12 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:13:9: 警告: 関数 ‘read’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   13 |         read(0,buf,16);
      |         ^~~~
main.c:47:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   47 |         write(1,buf,(char*)wp-(char*)buf);
      |         ^~~~~
main.c:48:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   48 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

long buf[200000];
long*wp=buf;
char*rp=buf;

#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

#define WT(v) {long _z=v,_d=0x2020202020202020l;while(_d=_d<<8|0x30|_z%10,_z/=10);*wp++=_d;}

main(){
	read(0,buf,16);
	RD(n);
	RD(k);
	int m=n/k;
	if(k>1&k==n|~k&m&1){
		*wp++=*(long*)"No      ";
	}else{
		*wp++=*(long*)"Yes     ";
		if(k==1){
			for(int i=1;i<=n;++i){
				WT(i);
			}
		}else{
			int g=m-(m&1?3:0)>>1;
			int h=n-k*3>>1;
			int i2=k>>1;
			int i3=0;
			for(int i=0;i<k;++i){
				if(m&1){
					WT(h+1+i);
					WT(h+1+k+i2);
					WT(h+3*k-i3);
					i2+=1;
					if(i2>=k)i2-=k;
					i3+=2;
					if(i3>=k)i3-=k;
				}
				for(int j=0;j<g;++j){
					WT(i+j*k+1);
					WT(n-i-j*k);
				}
			}
		}
	}
	write(1,buf,(char*)wp-(char*)buf);
	_exit(0);
}
0