hehehehe pastebin Q1 #include using namespace std; #define INF 100000 struct Edge{ int a; int b; }; int main(){ hehehehe pastebin How to use it? hehehehe pastebin ios::sync_with_stdio(false); cin.tie(0); int e; int all = 0; int MAX = 1; string u, v; int a, b; while(cin>>e){ MAX = 1; hehehehe pastebin How to get it for free? hehehehe pastebin vector name; vector> cost; vector edges; for(int i = 0 ; i < e ; i++){ cin>>u>>v; all = 0; for(int j = 0 ; j < (int)name.size() ; j++){ if(u == name[j]){ all += 10; hehehehe pastebin How to get it? hehehehe pastebin a = j; } else if(v == name[j]){ all += 1; b = j; } if(all == 11)break; } if(u == v){ b = a; hehehehe pastebin How to get it? hehehehe pastebin } if(all == 0){ if(u == v){ a = (int)name.size(); name.push_back(u); b = a; } else{ a = (int)name.size(); hehehehe pastebin How to use it? hehehehe pastebin name.push_back(u); b = (int)name.size(); name.push_back(v); } } else if(all == 1){ a = (int)name.size(); name.push_back(u); } else if(all == 10){ hehehehe pastebin How to dowload it? hehehehe pastebin if(u != v){ b = (int)name.size(); name.push_back(v); } } if(a != b) edges.push_back({a, b}); } cost.resize((int)name.size()); hehehehe pastebin PasteShr hehehehe pastebin for(int i = 0 ; i < (int)name.size() ; i++){ cost[i].resize((int)name.size(), INF); cost[i][i] = 0; } for(int i = 0 ; i < (int)edges.size() ; i++){ cost[edges[i].a][edges[i].b] = 1; cost[edges[i].b][edges[i].a] = 1; } hehehehe pastebin How to use it? hehehehe pastebin for(int i = 0 ; i < (int)cost.size() ; i++){ for(int j = 0 ; j < (int)cost.size() ; j++){ for(int k = 0 ; k < (int)cost.size() ; k++){ if(cost[j][k] > (cost[j][i] + cost[i][k])){ cost[j][k] = cost[j][i] + cost[i][k]; //MAX = max(MAX, cost[j][k]); } } } } hehehehe pastebin How to get it for free? hehehehe pastebin /*for(int i = 0 ; i < cost.size() ; i++){ for(int j = 0 ; j < cost.size() ; j++){ cout< using namespace std; int main(){ int l, r, s; hehehehe pastebin How to use it? hehehehe pastebin while(cin>>l>>r>>s){ vector locrad; vector> adj[l]; vector shelter; int start; long rad; int a, b, c; for(int i = 0 ; i < l ; i++){ cin>>rad; hehehehe pastebin How to use it? hehehehe pastebin locrad.push_back(rad); } for(int i = 0 ; i < r ; i++){ cin>>a>>b>>c; adj[a].push_back({b, c}); adj[b].push_back({a, c}); } for(int i = 0 ; i < s ; i++){ cin>>a; shelter.push_back(a); hehehehe pastebin How to get it for free? hehehehe pastebin } cin>>start; vector cumrad(l, INT_MAX); cumrad[start] = locrad[start]; priority_queue, vector>, greater>> pq; pq.push({locrad[start], start}); while(!pq.empty()){ int a = pq.top().second; hehehehe pastebin PasteShr hehehehe pastebin pq.pop(); for(auto u : adj[a]){ int b = u.first, w = u.second; if(cumrad[a] + w + locrad[b] < cumrad[b]){ cumrad[b] = cumrad[a] + w + locrad[b]; pq.push({cumrad[b], b}); } } } int minrad = INT_MAX; hehehehe pastebin PasteShr hehehehe pastebin for(int i = 0 ; i < s ; i++){ minrad = min((long)minrad, cumrad[shelter[i]]); } if(minrad >= INT_MAX)minrad = -1; cout< using namespace std; int n, m, c, r; bool BFS(vector> &rGraph, int s, int t, vector &parent){ vector visited(rGraph.size(), false); queue q; hehehehe pastebin How to dowload it? hehehehe pastebin q.push(s); visited[s] = true; parent[s] = -1; int u; while(!q.empty()){ u = q.front(); q.pop(); for(int v = 0 ; v < (int)rGraph.size() ; ++v){ if(!visited[v] && rGraph[u][v] > 0){ hehehehe pastebin How to dowload it? hehehehe pastebin q.push(v); parent[v] = u; visited[v] = true; } } } return visited[t] == true; } hehehehe pastebin PasteShr hehehehe pastebin int FF(vector> &graph, int s, int t){ int u, v; vector> rGraph(n+m+2); for(int i = 0 ; i < (int)rGraph.size() ; i++){ rGraph[i].resize(n+m+2); } for(u = 0 ; u < (int)rGraph.size() ; u++){ for(v = 0 ; v < (int)rGraph.size() ; v++){ rGraph[u][v] = graph[u][v]; hehehehe pastebin How to get it for free? hehehehe pastebin } } vector parent(rGraph.size()); int max_flow = 0; while(BFS(rGraph, s, t, parent)){ int path_flow = INT_MAX; for(v = t ; v != s ; v = parent[v]){ hehehehe pastebin How to use it? hehehehe pastebin u = parent[v]; path_flow = min(path_flow, rGraph[u][v]); } for (v = t; v != s; v = parent[v]) { u = parent[v]; rGraph[u][v] -= path_flow; rGraph[v][u] += path_flow; } hehehehe pastebin How to dowload it? hehehehe pastebin max_flow += path_flow; } return max_flow; } int main(){ ios::sync_with_stdio(false); cin.tie(0); hehehehe pastebin How to get it? hehehehe pastebin while(cin>>n>>m>>c>>r){ vector> graph(n+m+2); for(int i = 0 ; i < (int)graph.size() ; i++){ graph[i].resize(graph.size(), 0); } int student, num, time; for(int i = 1 ; i <= m ; i++){ graph[0][i] = 1; cin>>student>>num; for(int j = 0 ; j < num ; j++){ hehehehe pastebin How to dowload it? hehehehe pastebin cin>>time; graph[i][m+1+time] = 1; } } int ts; for(int i = 0 ; i < r ; i++){ for(int j = 0 ; j < n ; j++){ graph[m+1+j][m+n+1] = 0; } hehehehe pastebin PasteShr hehehehe pastebin cin>>ts; for(int j = 0 ; j < ts ; j++){ cin>>time; graph[m+1+time][m+n+1] = c; } cout<