Commit 216a0b97d24fddd83a32c704eed8976dc42c8a77

Authored by Ronaldo
1 parent ecebb05d7b
Exists in main

Create directory Unordered_Map and file Inscrito.cpp.

Showing 1 changed file with 42 additions and 0 deletions Side-by-side Diff

SearchingSortingandBasicDataStructures/Unordered_Map/Inscrito.cpp View file @ 216a0b9
  1 +//
  2 +// Created by ronal on 3/2/2023.
  3 +// Problem Link Description.
  4 +// https://br.spoj.com/problems/INSCRICO/
  5 +
  6 +#include <bits/stdc++.h>
  7 +
  8 +using namespace std;
  9 +
  10 +void Inscricao(vector<string>& Ins){
  11 + unordered_map<string, int> mp;
  12 +
  13 + for(auto str : Ins){
  14 + mp[str]++;
  15 + }
  16 +
  17 + for(auto value : Ins){
  18 + if(mp[value] != - 1){
  19 + cout << value << " " << mp[value] << "\n";
  20 + mp[value] = - 1;
  21 + }
  22 + }
  23 +}
  24 +
  25 +int main(){
  26 + ios_base::sync_with_stdio(false);
  27 + cin.tie(NULL);
  28 + vector<string> Ins;
  29 + string name, institution;
  30 + int size;
  31 +
  32 + cin >> size;
  33 + while(size != 0){
  34 + for(int i = 0; i < size; i++){
  35 + cin >> name >> institution;
  36 + Ins.push_back(institution);
  37 + }
  38 + cin >> size;
  39 + }
  40 + Inscricao(Ins);
  41 + return 0;
  42 +}