# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
108808 | 2019-05-02T08:17:25 Z | tictaccat | Airline Route Map (JOI18_airline) | C++14 | 0 ms | 0 KB |
#include "Boblib.h" #include <cassert> #include <cstdio> #include <bits/stdc++.h> using namespace std; void Bob( int V, int U, int C[], int D[] ){ vector<vector<int>> adj(V); for (int i = 0; i < U; i++) { adj[C[i]].push_back(D[i]); adj[D[i]].push_back(C[i]); } int spec = max_element(adj.begin(),adj.end(),[](vector<int> &a, vector<int> &b){return a.size() < b.size();}) - adj.begin(); vector<bool> special(V,false); for (int i: adj[spec]) { special[i] = true; } vector<int> actual(V,-1); int N = 0; for (int i = 0; i < V; i++) { if (i == spec) continue; int c = 0; for (int j: adj[i]) { if (special[j]) c++; } if (c > 0) { actual[i] = c-1; N++; } } // cout << N << "\n"; vector<pair<int,int>> el; for (int i = 0; i < U; i++) { if (actual[C[i]] != -1 && actual[D[i]] != -1) { el.push_back(make_pair(actual[C[i]],actual[D[i]])); } } InitMap(N,el.size()); for (auto p: el) { MakeMap(p.first,p.second); } // InitMap( 3, 2 ); // MakeMap( 1, 2 ); // MakeMap( 1, 3 ); }