FEgor04

Mutants

May 29th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. map<int, int> mutants;
  4. int main() {
  5.     freopen("mutants.in", "r", stdin);
  6.     freopen("mutants.out", "w", stdout);
  7.     int n, m, temp;
  8.     cin >> n;
  9.     for(int i = 0; i < n; i++) {
  10.         cin >> temp;
  11.         if(mutants.find(temp) != mutants.end()) {
  12.             mutants[temp]++;
  13.         }
  14.         else {
  15.             mutants[temp] = 1;
  16.         }
  17.     }
  18.     cin >> m;
  19.     for(int i = 0; i < m; i++) {
  20.         cin >> temp;
  21.         if(mutants.find(temp) != mutants.end()) {
  22.             cout << mutants[temp];
  23.         }
  24.         else {
  25.             cout << 0;
  26.         }
  27.         cout << endl;
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment