Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
map<string, string> mp1;
for(int i = 0; i < n; ++i) {
string s1, s2;
cin >> s1 >> s2;
mp1[s2] = s1;
}
for(int i = 0; i < m; ++i) {
string s1, s2;
cin >> s1 >> s2;
cout << s1 << ' ' << s2 << " #" << mp1[s2.substr(0, s2.size() - 1)] << endl;
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
2 2
main 192.168.0.2
replica 192.168.0.1
block 192.168.0.1;
proxy 192.168.0.2;
main 192.168.0.2
replica 192.168.0.1
block 192.168.0.1;
proxy 192.168.0.2;
Output
block 192.168.0.1; #replica
proxy 192.168.0.2; #main
proxy 192.168.0.2; #main
Demonstration
Codeforces Solution-Radio Station-Solution in C, C++, Java, Python