結果
問題 |
No.529 帰省ラッシュ
|
ユーザー |
![]() |
提出日時 | 2025-03-15 17:35:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,598 bytes |
コンパイル時間 | 1,957 ms |
コンパイル使用メモリ | 168,852 KB |
実行使用メモリ | 28,636 KB |
最終ジャッジ日時 | 2025-03-15 17:35:48 |
合計ジャッジ時間 | 12,327 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 2 WA * 4 RE * 4 TLE * 1 -- * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } inline void print(int x){ static int s[20],t=0; do s[++t]=x%10,x/=10;while(x); while(t) putchar(s[t--] + '0'); } const int N=1e5+5; struct edge{ int v,id; }; int n,m,q; priority_queue<int> a[N]; bool vis[N]; vector<edge> g[N]; int dfs(int u,int t,int mx){ int ret=0; if(a[u].top()>a[mx].top())mx=u; if(u==t)ret=mx; for(edge i:g[u]){ int v=i.v; if(vis[i.id])continue; vis[i.id]=1; ret=max(ret,dfs(v,t,mx)); } return ret; } int calc(int x,int y){ memset(vis,0,sizeof(vis)); int t=dfs(x,y,0),tt=a[t].top(); if(tt!=-1)a[t].pop(); return tt; } signed main(){ // freopen("visit.in","r",stdin); // freopen("visit.out","w",stdout); cin>>n>>m>>q; for(int i=1;i<=m;i++){ int u=read(),v=read(); g[u].push_back({v,i}); g[v].push_back({u,i}); } for(int i=0;i<=n;i++) a[i].push(-1); while(q--){ int op=read(),x=read(),y=read(); if(op==1) a[x].push(y); else cout<<calc(x,y)<<"\n"; } return 0; } // ????????????????????????? // ?????????????????? // ???????????????????????????????????? // ??????????????????????????????? // ???????????? // ???????????? // ???????????? // ???????????????????? // ???????????????????? // ???????????????????????????????? // ??????????????????????? // ??????????? // ?????????????