結果

問題 No.2657 Falling Block Game
コンテスト
ユーザー 👑 tails
提出日時 2024-03-02 15:31:31
言語 C90(gcc15)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,273 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 26,292 KB
最終ジャッジ日時 2026-02-24 01:18:02
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'f1':
main.c:22:14: error: expected ';' before 'y'
   22 |         rrep(y,h-1){
      |              ^
main.c:8:33: note: in definition of macro 'rrep'
    8 | #define rrep(v,e) for(typeof(e) v=e;v--;)
      |                                 ^
main.c:22:14: error: 'y' undeclared (first use in this function)
   22 |         rrep(y,h-1){
      |              ^
main.c:8:37: note: in definition of macro 'rrep'
    8 | #define rrep(v,e) for(typeof(e) v=e;v--;)
      |                                     ^
main.c:22:14: note: each undeclared identifier is reported only once for each function it appears in
   22 |         rrep(y,h-1){
      |              ^
main.c:8:37: note: in definition of macro 'rrep'
    8 | #define rrep(v,e) for(typeof(e) v=e;v--;)
      |                                     ^
main.c:25:21: error: expected ';' before 'x'
   25 |                 rep(x,w){
      |                     ^
main.c:7:32: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c:25:21: error: 'x' undeclared (first use in this function)
   25 |                 rep(x,w){
      |                     ^
main.c:7:36: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                    ^
main.c:41:22: error: expected ';' before 'x'
   41 |                 rrep(x,w){
      |                      ^
main.c:8:33: note: in definition of macro 'rrep'
    8 | #define rrep(v,e) for(typeof(e) v=e;v--;)
      |                                 ^
main.c:56:21: error: expected ';' before 'x'
   56 |                 rep(x,w){
      |                     ^
main.c:7:32: note: in definition of macro 'rep'
    7 | #define rep(v,e) for(typeof(e) v=0;v<e;++v)
      |                                ^
main.c: In function 'f2':
main.c:65:14: error: expected ';' before 'x'
   65 |         rrep(x,w){
      |              ^
main.c:8:33: note: in definit

ソースコード

diff #
raw source code

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define rrep(v,e) for(typeof(e) v=e;v--;)
#define max(a,b) (a>=b?a:b)
#define chmin(v,a) (v=v<=a?v:a)

char wbuf[1<<25];
int a[100000];
int b[100000];
int q[100000];

int f1(){
	rd_init();
	int h=rd();
	int w=rd();
	rp+=(w+1)*(h-1);
	rrep(y,h-1){
		rp-=w+1;
		int qr=0,qw=-1;
		rep(x,w){
			if(*rp++=='#'){
				qr=0,qw=-1;
				b[x]=w;
			}else{
				while(qr<=qw&&a[q[qw]]>=a[x]){
					--qw;
				}
				q[++qw]=x;
				while(qr<qw&&x-q[qr]>=a[q[qr+1]]){
					++qr;
				}
				b[x]=max(x-q[qr],a[q[qr]]);
			}
		}
		qr=0,qw=-1;
		rrep(x,w){
			if(*--rp=='#'){
				qr=0,qw=-1;
			}else{
				while(qr<=qw&&a[q[qw]]>=a[x]){
					--qw;
				}
				q[++qw]=x;
				while(qr<qw&&q[qr]-x>=a[q[qr+1]]){
					++qr;
				}
				int t=max(q[qr]-x,a[q[qr]]);
				chmin(b[x],t);
			}
		}
		rep(x,w){
			a[x]=b[x];
		}
	}
	return w;
}

void f2(int w){
	char*wp=wbuf+sizeof wbuf;
	rrep(x,w){
		*--wp='\n';
		wt(a[x]);
	}
	write(1,wp,wbuf+sizeof wbuf-wp);
}

int main(){
	f2(f1());
	_exit(0);
}
0