选项前都是一个字母带个点,可以一起统计长度,用pair让字母跟着选项排序

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main() {
    int t;cin>>t;
    while(t--){
        vector<pair<int,char>>arr;
        string s;
        for(int i=0;i<4;++i){
            cin>>s;
            arr.push_back(pair<int,char>(s.size(),'A'+i));
        }
        sort(arr.begin(),arr.end());
        if(arr[0].first<arr[1].first&&arr[2].first==arr[3].first)cout<<arr[0].second<<endl;
        else if(arr[0].first==arr[1].first&&arr[2].first<arr[3].first)cout<<arr[3].second<<endl;
        else cout<<'C'<<endl;
    }
}
// 64 位输出请用 printf("%lld")