有啥意义。。
by _5011_ @ 2020-10-20 21:47:07
sqlm
by 佐世保の时雨 @ 2020-10-20 21:47:48
sqlm
by 猫猬兽 @ 2020-10-20 21:48:35
和@[Peal_Frog](/user/44805) 的毒瘤程度有一拼
by Schwarzkopf_Henkal @ 2020-10-20 21:49:14
naive!不用压都比你短
```cpp
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,M=N<<1,P=M<<1;
unsigned d[M],len[P];
int he[M],to[P],ne[P],f[M],g[M],fa[23][M];
bool b[N];
struct E{
int u,v,a;
bool operator<(E x)const{return a>x.a;}
}e[M];
priority_queue<pair<unsigned,int> >q;
int gf(int x){return f[x]==x?x:f[x]=gf(f[x]);}
void dfs(int x,int y){
int i,j;
fa[0][x]=y;
for(i=0;i<20;++i)fa[i+1][x]=fa[i][fa[i][x]];
for(i=he[x];i;i=ne[i])dfs(j=to[i],x),d[x]=min(d[x],d[j]);
}
int main(){
unsigned l;
int n,m,i,j,k,t,c,T;
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&m),t=0,memset(he,0,n+1<<2);
for(i=1;i<=m;++i)cin>>e[i].u>>e[i].v>>l>>e[i].a,ne[++t]=he[e[i].u],to[t]=e[i].v,len[t]=l,he[e[i].u]=t,ne[++t]=he[e[i].v],to[t]=e[i].u,len[t]=l,he[e[i].v]=t;
sort(e+1,e+m+1),memset(d,127,n+1<<3),memset(b,0,n+1),d[1]=0,q.push({0,1});
while(!q.empty()){
i=q.top().second,q.pop();
if(!b[i])for(j=he[i],b[i]=1;j;j=ne[j])if(k=to[j],l=d[i]+len[j],d[k]>l)d[k]=l,q.push({-l,k});
}
for(l=t=0,c=n,i=1;i<=n;++i)f[i]=i;
for(memset(he,0,n+1<<3),i=1;i<=m;++i)if(j=gf(e[i].u),k=gf(e[i].v),j!=k)g[++c]=e[i].a,f[j]=f[k]=f[c]=c,ne[++t]=he[c],to[t]=k,he[c]=t,ne[++t]=he[c],to[t]=j,he[c]=t;
for(dfs(c,0),cin>>m>>k>>c;m--;){
cin>>i>>j,i=(i+k*l-1)%n+1,j=(j+k*l)%(c+1);
for(t=20;~t;--t)if(g[fa[t][i]]>j)i=fa[t][i];
l=d[i],cout<<l<<'\n';
}
}
}
```
by panyf @ 2020-10-20 21:50:39
sqlm
by Stuch @ 2020-10-20 21:57:29
sqlm
by zplqwq @ 2020-10-20 22:00:20
sqlm
by hanzizhou @ 2020-10-20 22:01:24
# 更新:长度1270
```cpp
#include<bits/stdc++.h>
#define R(i,r) for(I i=1;i<=r;i++)
#define P(r,l) for(I i=r;i>=l;i--)
#define M(a,b) memset(a,b,sizeof a)
#define I int
#define cm(x,y) bool operator<(const x&b)const{return y;}
using namespace std;const I N=2e5+5;
I n,m,q,k,s,u,v,w,lst,C,H[N],d[N*2],sz,U[N*2],f[N*2][18],a[N*2],T;
struct ed{I v,nxt,w;}e[N*4];
void add(I u,I v,I w){e[++C]=(ed){v,H[u],w};H[u]=C;}
struct no{I u,d;cm(no,d>b.d)};
void dji(){priority_queue<no>q;M(d,63),d[1]=0,q.push((no){1,0});while(!q.empty()){no t=q.top();q.pop();if(t.d>d[t.u])continue;for(I i=H[t.u],v;v=e[i].v;i=e[i].nxt)if(t.d+e[i].w<d[v])q.push((no){v,d[v]=t.d+e[i].w});}}
struct Ed{I u,v,w;cm(Ed,w>b.w)}E[N*2];
I fi(I x){return x==U[x]?x:U[x]=fi(U[x]);}
void kru(){M(H,C=0),M(f,0),sz=n;R(i,n*2-1)U[i]=i;sort(E+1,E+m+1);R(i,m)if((u=fi(E[i].u))^(v=fi(E[i].v))){a[f[u][0]=U[u]=f[v][0]=U[v]=++sz]=E[i].w;d[sz]=min(d[u],d[v]);if(sz==n*2-1)break;}P(sz,1)R(j,17)f[i][j]=f[f[i][j-1]][j-1];}
I main(){cin>>T;while(T--){cin>>n>>m;M(H,lst=C=0);R(i,m){scanf("%d%d%d%d",&E[i].u,&E[i].v,&w,&E[i].w);add(E[i].u,E[i].v,w),add(E[i].v,E[i].u,w);}dji(),kru();cin>>q>>k>>s;while(q--){scanf("%d%d",&u,&w);u=(u+k*lst-1)%n+1;w=(w+k*lst)%(s+1);P(17,0)if(f[u][i]&&a[f[u][i]]>w)u=f[u][i];printf("%d\n",lst=d[u]);}}}
```
by jingsichao @ 2020-10-20 22:05:33
@[Schwarzkopf_Henkal](/user/251723) ???
by Leap_Frog @ 2020-10-20 22:09:52