結果
| 問題 |
No.124 門松列(3)
|
| コンテスト | |
| ユーザー |
tails
|
| 提出日時 | 2020-10-27 09:56:40 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,118 bytes |
| コンパイル時間 | 207 ms |
| コンパイル使用メモリ | 32,880 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 21:52:15 |
| 合計ジャッジ時間 | 1,270 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
コンパイルメッセージ
main.c:22:1: warning: return type defaults to 'int' [-Wimplicit-int]
22 | main(){
| ^~~~
main.c: In function 'main':
main.c:24:9: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration]
24 | read(0,rbuf,sizeof rbuf);
| ^~~~
main.c:59:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
59 | printf("%d",z);
| ^~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
+++ |+#include <stdio.h>
1 | // original:
main.c:59:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
59 | printf("%d",z);
| ^~~~~~
main.c:59:9: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
// original:
// https://yukicoder.me/submissions/8485
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
//char*mmap();
char rbuf[24*1024];
#define RD(v) int v=0;{int c;while(c=*rp++-48,c>=0)v=v*10+c;}
#define RDL(v) long v=0;{int c;while(c=*rp++-48,c>=0)v=v*10+c;}
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
char q[200000], *qr=q, *qw=q;
int dist[64][128][128];
static inline int isK(int a, int b , int c){
return !a||a!=c&&(a<b&&b>c||a>b&&b<c);
}
main(){
//char*rp=mmap(0l,24l*1024,1,2,0,0ll);
read(0,rbuf,sizeof rbuf);
char*rp=rbuf;
RD(w);
RD(h);
dist[0][0][0] = 1;
*qw++ = 0;
*qw++ = 0;
*qw++ = 0;
int z=-1;
while(qw-qr){
int k=*qr++;
int y=*qr++;
int x=*qr++;
if(x+y==w+h-2){
z=dist[k][y][x]-1;
break;
}
int nk=rp[y*w+x<<1];
int d;
rep(d,4){
int ny=y+(d==2)-(d==0);
int nx=x+(d==3)-(d==1);
if(ny < 0 || ny >= h || nx<0 || nx>= w) continue;
if(!isK(k,nk,rp[ny*w+nx<<1])) continue;
if(dist[nk][ny][nx] > 0) continue;
dist[nk][ny][nx] = dist[k][y][x] + 1;
*qw++ = nk;
*qw++ = ny;
*qw++ = nx;
}
}
printf("%d",z);
}
tails