結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 4 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,376 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 0 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 0 ms
4,376 KB
testcase_19 AC 0 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:51:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   51 |         write(1,buf,(char*)wp-(char*)buf);
      |         ^~~~~
main.c:52:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   52 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

long buf[200001];
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 h1=(n-k*3>>1)+1;
			int h2=h1+k;
			int h3=h2+k+k-1;
			int i2=k>>1;
			int i3=0;
			int x=0;
			int y=n;
			for(int i=0;i<k;++i){
				if(m&1){
					WT(h1+i);
					WT(h2+i2);
					WT(h3-i3);
					i2+=1;
					i2-=i2<k?0:k;
					i3+=2;
					i3-=i3<k?0:k;
				}
				for(int j=0;j<g;++j){
					WT(++x);
					WT(y--);
				}
			}
		}
	}
	write(1,buf,(char*)wp-(char*)buf);
	_exit(0);
}
0