pat:1013. Battle over Cities AC

Source: Internet
Author: User

#include<stdio.h>#include<string.h>#include<vector>Usingnamespace Std;Constint max=1010;int n,m,k;Number of cities, highways, number of queriesint DELETE;The point to delete vector<Int> Adj[max];adjacency tableBOOL Vis[max];void DFS (int s) {if (delete==s)ReturnIndicates that the point is not up to vis[s]=TrueForint i=0; I<adj[s].size (); ++i)if (vis[adj[s][i]]==False) DFS (Adj[s][i]);}int main () {scanf ("%d%d%d", &n,&m,&k);Forint i=0; I<m; ++i) {int u,v; scanf"%d%d", &u,&v); Adj[u].push_back (v); Adj[v].push_back (U); }Forint q=0; q<k; ++q) {int cnt=< Span class= "integer" >0; //number of disconnected graphs scanf ( "%d< Span class= "delimiter", &delete); memset (Vis,false,sizeof (VIS)); for (int i=1; i<=n; ++i) {if (vis[i]==false && i!=delete) {DFS (i); ++cnt;}} printf ( "%d\n1); } return 0;}          

pat:1013. Battle over Cities (+) AC

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.