#45650: klay thomspon 11


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:59:45

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    string result; // 儲存答案的字串
    int min=2147483647; // 儲存最小的相異字母數量
    for(int i=0;i<N;i++){
        string str;
        cin>>str;
        bool a[26]={false}; // 用來記錄已經出現過的字母
        int count=0; // 記錄當前字串的相異字母數量
      for(int j=0;j<str.length();j++){   // 檢查字串的每個字母
          if(!a[str[j]-'A']){ // 如果這個字母出現過
              a[str[j]-'A']=true; // 標記為已出現
              count++; // 相異字母數量加1
          }
      }
        if(count<min||count==min&&str<result){ // 如果找到更少的相異字母數,或相同但字典序更小
            min=count; // 更新最小相異字母數
            result=str; // 更新結果字串
        }
    }
    cout<<result<<endl;
    return 0;
}
#45651: Re: klay thomspon 11


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [60.248.154.139]
最後登入時間 :
2025-08-21 12:59:45