Come home Time Limit: 4000 Ms memory limit: 65536 k any questions? Click Here ^_^ The topic Description provides a undirected and untitled graph with n (1 <= n <= 1000) vertices and M (1 <= m <= 1000000) edges. The vertex number ranges from 1 to n. The M side may have duplicate edges. Ask how many remaining edges are removed from the duplicate edges. Multiple Input groups. The first line of input for each group contains two integers n and M. In the next m row, each line contains two integers U and V, indicating an edge between two points. Output an integer to indicate the answer. Sample Input
2 31 21 22 13 31 11 33 22 21 11 1
Sample output
131
Okay .. Shui Fa
#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <iostream>#include <algorithm>#include <vector>#include <stack>using namespace std;bool ma[1002][1002];int main(){int n,m;while(~scanf("%d%d",&n,&m)){int u,v;memset(ma,0,sizeof(ma));int ans=m;for(int i=1;i<=m;i++){scanf("%d%d",&u,&v);if(!ma[u][v])ma[u][v]=ma[v][u]=1;elseans--;}printf("%d\n",ans);}return 0;}
Sdut 2829-coming to question a (Adjacent matrix)