Uvalive 7456 Least Crucial Node (and episode + Violence)

Source: Internet
Author: User
Tags cmath

Test instructions: The largest cutting point with the smallest marking. (When you delete the point, the specified point #sink can reach the maximum number of points).

Analysis: Because we do not know which node to remove, and because there are only 100 nodes, so we consider a violent, all the nodes to go once, and then use and check set to judge.

The code is as follows:

#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < cmath> #include <stack> #define FREOPENR freopen ("In.txt", "R", stdin) #define FREOPENW freopen ("OUT.txt", "W",  STDOUT) using namespace Std;typedef long Long ll;typedef pair<int, int> p;const int inf = 0x3f3f3f3f;const double inf = 0x3f3f3f3f3f3f;const LL LNF = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = 1E3 + 100;const int mod = 1e9 + 7;const int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};const char *hex[] = {"0000", "  0001 "," 0010 "," 0011 "," 0100 "," 0101 "," 0110 "," 0111 "," "," 1001 "," 1010 "," 1011 "," 1100 "," 1101 "," 1110 "," 1111 "};int N, m;const int mon[] = {0, 31, 28, 31, 30, 31, 30, [0], +, +, +, 31};const int monn[] = (= {+), H, H, H, +, +,,,,, int, int. b) {return a < b a:b;} inline int Max (int a, int b) {return a > b a:b;} inline ll Min (ll A, ll b) {return a < b a:b;} inline ll Max (ll A, ll b) {return a > b a:b;} inline bool Is_in (int r, int c) {return R >= 0 && r < n && C >= 0 && C < m;} int x;vector<p> v;int p[105];int Find (int x) {return x = = P[x]? x:p[x] = Find (P[x]);}        int main () {while (scanf ("%d", &n) = = 1 && N) {scanf ("%d", &x);        scanf ("%d", &m);        int u, VV;        V.clear ();            for (int i = 0; i < m; ++i) {scanf ("%d%d", &u, &AMP;VV);        V.push_back (P (U, vv));        } int ans = 0, cnt = 0;            for (int i = 1; I <= n; ++i) {if (i = = x) continue;            for (int j = 1; j <= N; ++j) p[j] = j; for (int j = 0; J < v.size (); ++J) {u = V[j].first;                VV = V[j].second;                if (U = = I | | vv = = i) continue;                int x = Find (u);                int y = Find (vv);            if (x! = y) p[y] = x;            } Map<int, int> MP;            Map<int, int>:: iterator it;            for (int j = 1; j <= N; ++j) if (i! = j) ++mp[find (j)];            if (Mp.size () <= 1) continue;            int y = Find (x);                if (CNT < n-mp[y]-1) {cnt = n-mp[y]-1;            ans = i;    }} printf ("%d\n", ans); } return 0;}

Uvalive 7456 Least Crucial Node (and episode + Violence)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.