PUBG HACK- Editorial || PBHACK

PROBLEM LINK: PUBG HACK | CodeChef

Problem Code: PUBG HACK | CodeChef

Practice: CodeChef | Competitive Programming | Participate & Learn | CodeChef

Contest : Campus Code Coding Competition | CodeChef

Author: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Tester: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9
Editorialist: Codechef Adgitm Chapter : https://www.codechef.com/users/test_account_9

DIFFICULTY:

Easy

PREREQUISITES:

Basic Searching and Compairing.

PROBLEM:

Your PUBG game has been hacked, The hacker changed the name of each player in a team in anagrams of a random word. The only way to differentiate your team members is finding everyone whose name is now an anagram of your name. write a program to find your teammates.

EXPLANATION:
For example, given name list [‘eat’, ‘ate’, ‘apt’, ‘pat’, ‘tea’, ‘now’] and your name as ‘eta’ your team members are [‘eat’ ‘ate’ ‘tea’]

SOLUTION:
C++:

#include<bits/stdc++.h>

#define deb(x) cerr<<"["<<#x<<" : “<<x<<”]\n";
#define int long long int
#define endl ‘\n’
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007

using namespace std;

void solve()
{
string ur_name; cin >> ur_name;
sort(ur_name.begin(), ur_name.end());
int n; cin >> n;
vector ans;
while (n–) {
string mem_name;
cin >> mem_name;

	string temp = mem_name;
	sort(mem_name.begin(), mem_name.end());
	if (ur_name == mem_name) {
		ans.push_back(temp);
	}
}
sort(ans.begin(), ans.end())
;	for (int i = 0; i < ans.size(); i++) {
	cout << ans[i] << " ";
}

}

int32_t main() {
FASTIO;
Read_My_File();
int t = 1;
while (t–)
{
solve();
}
return 0;
}