1.Counting Roads - AtCoder abc061_b - Virtual Judge (vjudge.net)
利用数组的值去替换数组的下标来简化计数过程
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int n,m,a[51],b[51],c[51] = {0}; 5 6 int main(){ 7 cin >> n >> m; 8 for (int i = 1; i <= m; i ++ ) 9 { 10 cin >> a[i] >> b[i]; 11 c[a[i]] += 1; c[b[i]]+= 1; 12 } 13 14 for (int i = 1; i <= n; i ++ ) 15 cout << c[i] << endl; 16 return 0; 17 }View Code
标签:哈希,int,51,Virtual,计数,数组 From: https://www.cnblogs.com/rw666/p/17812734.html