2019-06-19 15:48:39 C++

C++

Copy Copied! Full
#include <bits/stdc++.h> using namespace std; #define ALL(A) (A).begin(),(A).end() #define p pair<int,int> #define ll long long const ll mod = 1e9+7; const ll INF = 2*1e18; const int inf = 1e9+7; priority_queue<p,vector<p>,greater<p>> q; vector<vector<pair<int,int>>> graph(105); int g[105][105]; void f (int start){ for(int i=1;i<105;i++)for(int j=1;j<105;j++){ if(i==j)continue; g[i][j]=inf; } for(int i=0;i<graph[start].size();i++){ q.push(graph[start][i]); } } int main(void){ int n,k; int a,b,c,d; ll ans; cin >> n >> k; for(int i=0;i<k;i++){ cin >> a; if(a==1){ cin >> b >> c >> d; graph[b].push_back(pair<int,int>(c,d)); graph[c].push_back(pair<int,int>(b,d)); }else{ cin >> b >> c; f(c); cout << g[b][c] << endl; } } }
RECOMMEND