結果
| 問題 |
No.416 旅行会社
|
| ユーザー |
tails
|
| 提出日時 | 2020-11-06 14:53:27 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 4,000 ms |
| コード長 | 1,782 bytes |
| コンパイル時間 | 582 ms |
| コンパイル使用メモリ | 40,192 KB |
| 実行使用メモリ | 20,992 KB |
| 最終ジャッジ日時 | 2024-12-14 20:56:17 |
| 合計ジャッジ時間 | 2,558 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
コンパイルメッセージ
main.c: In function 'main':
main.c:33:28: warning: implicit declaration of function 'time' [-Wimplicit-function-declaration]
33 | unsigned t=time(0);
| ^~~~
main.c:1:1: note: 'time' is defined in header '<time.h>'; did you forget to '#include <time.h>'?
+++ |+#include <time.h>
1 | #pragma GCC optimize("Ofast")
main.c:109:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
109 | write(1,wbuf+2,(n-1)*8);
| ^~~~~
main.c:110:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
110 | _exit(0);
| ^~~~~
| _Exit
ソースコード
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
char*mmap();
#define RD(v) int v=0;{int _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}
#define HASHSIZE 1000003
long hash[HASHSIZE];
int hash_k1;
int hash_k2;
long ab[200000];
long cd[200000];
int en[100001];
int ei[100001];
int eb[400000];
long wbuf[100001];
long d;
void f(int i){
if(!wbuf[i]){
wbuf[i]=d;
for(int k=0;k<en[i];++k){
f(eb[ei[i]+k]);
}
}
}
int main(){
{
unsigned t=time(0);
hash_k1=t%HASHSIZE?:1;
hash_k2=t/HASHSIZE?:1;
}
char*rp=mmap(0l,7l*800005,1,2,0,0ll);
RD(n);
RD(m);
RD(q);
for(int i=0;i<m;++i){
RD(a);
RD(b);
ab[i]=(long)a<<32|b;
++en[a];
++en[b];
}
{
int s=0;
for(int i=0;++i<=n;){
ei[i]=s;
s+=en[i];
en[i]=0;
}
}
for(int i=0;i<q;++i){
RD(c);
RD(d);
long e=(long)c<<32|d;
cd[i]=e;
int k=e%HASHSIZE*hash_k1%HASHSIZE;
int k2=e%HASHSIZE*hash_k2%HASHSIZE;
while(hash[k]){
k+=k2;
if(k>=HASHSIZE) k-=HASHSIZE;
}
hash[k]=e;
}
for(int i=0;i<m;++i){
long e=ab[i];
int k=e%HASHSIZE*hash_k1%HASHSIZE;
int k2=e%HASHSIZE*hash_k2%HASHSIZE;
while(hash[k]&&hash[k]!=e){
k+=k2;
if(k>=HASHSIZE) k-=HASHSIZE;
}
if(!hash[k]){
int a=e>>32;
int b=e;
eb[ei[a]+en[a]++]=b;
eb[ei[b]+en[b]++]=a;
}
}
d=-1;
f(1);
for(int i=q;i--;){
d=i+1;
int a=cd[i]>>32;
int b=cd[i];
if(wbuf[a]) f(b);
if(wbuf[b]) f(a);
eb[ei[a]+en[a]++]=b;
eb[ei[b]+en[b]++]=a;
}
for(int i=2;i<=n;++i){
int z=wbuf[i];
wbuf[i]=
z<0?0x0a2020202020312dl:
(z>=100000?z/100000%10+48l:32l)<< 0|
(z>= 10000?z/ 10000%10+48l:32l)<< 8|
(z>= 1000?z/ 1000%10+48l:32l)<<16|
(z>= 100?z/ 100%10+48l:32l)<<24|
(z>= 10?z/ 10%10+48l:32l)<<32|
z%10+0x0a2030l<<40;
}
write(1,wbuf+2,(n-1)*8);
_exit(0);
}
tails