結果
| 問題 | No.2316 Freight Train |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2023-05-26 23:15:17 |
| 言語 | C90 (gcc 15.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,055 bytes |
| 記録 | |
| コンパイル時間 | 273 ms |
| コンパイル使用メモリ | 26,452 KB |
| 最終ジャッジ日時 | 2026-02-24 01:14:19 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c: In function 'uf_init':
main.c:12:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
12 | for(int i=0;i<UFSIZE;++i){
| ^~~
main.c:12:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c: In function 'main':
main.c:44:13: error: expected ';' before 'i'
44 | rep(i,n){
| ^
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:44:13: error: 'i' undeclared (first use in this function)
44 | rep(i,n){
| ^
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:44:13: note: each undeclared identifier is reported only once for each function it appears in
44 | rep(i,n){
| ^
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:57:31: warning: multi-character character constant [-Wmultichar]
57 | *wp++='\nseY';
| ^~~~~~~
main.c:59:31: warning: multi-character character constant [-Wmultichar]
59 | *wp++='\n oN';
| ^~~~~~~
ソースコード
#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_skip() while(*rp++>=48)
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(typeof(e) v=0;v<e;++v)
#define UFSIZE 200002
int ufbuf[UFSIZE];
void uf_init(){
for(int i=0;i<UFSIZE;++i){
ufbuf[i]=-1;
}
}
int uf_root(int a){
int b;
int t=a;
while(b=ufbuf[t],b>=0) t=b;
while(b=ufbuf[a],b>=0) ufbuf[a]=t,a=b;
return t;
}
void uf_unite(int a,int b){
a=uf_root(a);
b=uf_root(b);
if(a!=b){
if(ufbuf[a]<ufbuf[b]){
ufbuf[a]+=ufbuf[b];
ufbuf[b]=a;
}else{
ufbuf[b]+=ufbuf[a];
ufbuf[a]=b;
}
}
}
unsigned wbuf[1<<20];
int main(){
uf_init();
rd_init();
int n=rd();
rd_skip();
rep(i,n){
if(*rp=='-'){
rp+=3;
}else{
int p=rd();
uf_unite(i+1,p);
}
}
unsigned*wp=wbuf;
while(*rp){
int a=rd();
int b=rd();
if(uf_root(a)==uf_root(b)){
*wp++='\nseY';
}else{
*wp++='\n oN';
}
}
write(1,wbuf,(wp-wbuf)*sizeof*wbuf);
_exit(0);
}
tails