-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprob_10132.cpp
65 lines (60 loc) · 1.32 KB
/
prob_10132.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <list>
#include <forward_list>
#define rep(i,a,b) for(i=a;i<b;++i)
#define vectIter(vect) for(auto &val: vect)
#define mapIter(map_) for(auto &val_: map_)
#define gc getchar_unlocked
using namespace std;
int main(){
int i,j,k,l,n;
map<string,int> freq;
string str;
vector<string> vect;
scanf("%d\n",&n);
while(n--){
int Bits=0;
while(getline(cin,str),str!=""){
Bits+=str.size();
vect.push_back(str);
}
int len= Bits/(vect.size()>>1);
for(auto iter= vect.begin(),end= vect.end();iter!=end;++iter){
for(auto iter1= iter; iter1!=end;++iter1){
str= (*iter)+(*iter1);
if(str.size()==len){
if(freq.find(str)==freq.end())
freq[str]= 1;
else ++freq[str];
str= (*iter1)+(*iter);
if(freq.find(str)==freq.end())
freq[str]= 1;
else ++freq[str];
}
}
}
// cout << freq.size() <<endl;
str= freq.begin()->first;
for(auto& val:freq)
if(val.second> freq[str])
str= val.first;
freq.erase(freq.begin(),freq.end());
vect.erase(vect.begin(),vect.end());
cout << str <<endl;
if(n)
cout <<endl;
}
}