'Why is I getting wronng answer in this code?
Can somebody tell me why I am getting wrong answer in this code? Can somebody help me solve this problem? It is a uva problem. problem number 11060.
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, k=0;
while(scanf("%d", &n) !=EOF){
k++;
int c = 0;
string v[n];
map <string, int > mp1;
multimap <int, string> mp2;
string a;
for(int i=0; i<n; i++){
cin >> a;
mp1[a]=0;
}
int m;
cin >> m;
string x, y;
for(int i=0; i<m; i++){
cin >> x >> y;
mp1[y]++;
}
for(auto it=mp1.begin(); it !=mp1.end();it++){
mp2.insert({it->second,it->first});
}
cout << "Case #"<< k << ": Dilbert should drink beverages in this order: ";
for(auto it=mp2.begin(); it!=mp2.end(); it++){
v[c]=it->second;
c++;
}
for(int i=0; i<n; i++){
if(i==n-1){
cout << v[i] <<"."<<endl;
continue;
}
cout << v[i] << " ";
}
}
return 0; }
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
