Codeforces Round # 566 (Div. 2) C (string, SET)

#include<bits/stdc++.h>
using namespace std;
string s[100007];
set<int>st[100007][7];
int t[207];
int a[100007],b[100007][2],c[100007],d[100007][2];
int main(){
t['a']=1;
t['e']=2;
t['i']=3;
t['o']=4;
t['u']=5;
int n;
cin>>n;
for(int i=1;i<=n;++i){
cin>>s[i];
int cnt=0;
char last;
for(int j=0;j<s[i].length();++j){
if(s[i][j]=='a'||s[i][j]=='e'||s[i][j]=='i'||s[i][j]=='o'||s[i][j]=='u'){
cnt++;
last=s[i][j];
}
}
if(cnt){
st[cnt][t[last]].insert(i);Int CNT1 = 0, CNT2 = 0;}
}


num1 = 0 int, num2 = 0;
for (int I =. 1; I <= 100000; I ++) {
num1 = 0;
for (int. 1 = J; J <=. 5; J ++) {
num2 = 0 ;
for (Auto IT: ST [i] [j]) {
a [num2 ++] = IT; // the i-ending vowels and vowel j number string into a serial array
}
for (int. 1 = K; K <num2; = K + 2) {// a string array to b taken array pairs, they all have the same number of vowels and the last letter
b [+ CNT1 +] [0] = a [K];
B [CNT1] [. 1] = a [K +. 1];
}
IF (& num2. 1) // a string array has a remaining number
c [++ num1] = a [num2]; // c array put into a single serial string, they all have the same number of vowel i, but not the end of the same vowel
}
for (int. 1 = J; J <num1; J + = 2) {// c string array pairs array taken to d, they have the same number of vowels, so that the end of different vowel them only in the first row of each
d [ CNT2 ++] [0] = C [J];
D [CNT2] [. 1] = C [J +. 1];
}
}
(CNT1 <= CNT2) have the same number of {// if the number of vowels less than different
cout << cnt1 << "\ n" ;
for (int I =. 1; I <= CNT1; I ++) {
COUT << S [D [I] [0]] << "" << S [B [I] [0]] << "\ n-";
COUT << S [D [I] [. 1]] <<" "<< S [B [I] [. 1]] <<" \ n-";
}
}
the else {
int + ANS = CNT2 (cnt1- cnt2) / 2; // have a larger number of the same number of vowels, giving priority to them and different to match, then twenty-two from pairs
cout << ANS << "\ the n-";
for (int i . 1 =; I <= CNT2; I ++) {
COUT << S [D [I] [0]] << "" << S [B [I] [0]] << "\ n-";
COUT S << [D [I] [. 1]] << "" << S [B [I] [. 1]] << "\ n-";
}
for (int I = + CNT2. 1; I <CNT1; I + 2 =) {
COUT << S [B [I] [0]] << "" << S [B [I +. 1] [0]] << "\ n-";
COUT << S [B [I ] [1]] << "" <<s[b[i+1][1]]<<"\n";
}
}
return 0;
}

Guess you like

Origin www.cnblogs.com/ldudxy/p/11184598.html