https://codeforces.com/contest/1182/problem/C

题解:贪心

1、分组:数量相同并且最后一个元音相同、数量相同、其他

2、首先第一组和第二组配对、其次第一组自配对;

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=1000000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
string str[N];
struct node{
    int id;
    int num;
    char str;
    bool operator < (const node &S)const{
        if(num==S.num){
            return str<S.str;
        }
        return num<S.num;
    }
}e[N];
char vowels[10]="aeoiu";
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    //scanf("%d",&t);
    cin>>n;
    for(int i=1;i<=n;i++){
        //scanf("%s",&str[]);
        cin>>str[i];
        e[i].id=i;
        for(int j=0;j<str[i].size();j++){
            for(int k=0;k<5;k++){
                if(str[i][j]==vowels[k]){
                    e[i].num++;
                    e[i].str=str[i][j];
                }
            }
        }
    }
    sort(e+1,e+n+1);
    //cout<<0<<endl;for(int i=1;i<=n;i++)cout<<str[e[i].id]<<endl;
    vector<string>str1,str2;
    vector<int>id1,id2;
    vector<int>S;
    for(int i=1;i<=n;i++){//cout<<i<<endl;
        if(i+1<=n&&e[i].num==e[i+1].num&&e[i].str==e[i+1].str){
            id1.push_back(i);
            id2.push_back(i+1);
            i++;
        }else{
            S.push_back(i);
        }
    }
    int pos=0;
    for(int i=0;i+1<S.size()&&pos<id1.size();i++){
        if(e[S[i]].num==e[S[i+1]].num){
            str1.push_back(str[e[S[i]].id]+" "+str[e[id1[pos]].id]);
            str2.push_back(str[e[S[i+1]].id]+" "+str[e[id2[pos]].id]);
            pos++;
            i++;
        }
    }
    for(int i=pos;i+1<id1.size();i+=2){//cout<<i<<endl;
        str1.push_back(str[e[id1[i]].id]+" "+str[e[id1[i+1]].id]);
        str2.push_back(str[e[id2[i]].id]+" "+str[e[id2[i+1]].id]);
    }
    cout<<str1.size()<<endl;
    for(int i=0;i<str1.size();i++){//cout<<i<<endl;
        cout<<str1[i]<<endl;
        cout<<str2[i]<<endl;
    }

#ifdef DEBUG
	printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif
    //cout << "Hello world!" << endl;
    return 0;
}