#45650: klay thomspon 11


1121226@stu.wghs.tp.edu.tw (Arthur✨小蜜蜂)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [112.104.66.104]
最後登入時間 :
2025-03-30 12:41:08
e313. 最少相異字母 -- 2018年10月APCS | From: [112.104.66.104] | 發表日期 : 2025-03-28 23:01

#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✨小蜜蜂)

學校 : 臺北市私立薇閣高級中學
編號 : 252772
來源 : [112.104.66.104]
最後登入時間 :
2025-03-30 12:41:08
e313. 最少相異字母 -- 2018年10月APCS | From: [112.104.66.104] | 發表日期 : 2025-03-28 23:02

https://tw.sports.yahoo.com/news/nba-%E5%B7%A7%E5%90%88-%E6%B9%AF%E6%99%AE%E6%A3%AE%E8%A7%A3%E5%AF%86%E9%81%B811%E8%99%9F%E5%8E%9F%E5%9B%A0-%E4%BA%BA%E7%94%9F%E5%85%85%E6%BB%BF%E6%AD%A4%E7%A5%9E%E7%A7%98%E6%95%B8%E5%AD%97-091726974.html

 
ZeroJudge Forum