1 条题解

  • 0
    @ 2026-10-25 14:06:59

    思路

    逗号和空格分词,保留首次最长最短并忽略空词。按题面规定的输入输出协议处理;数据、边界和算法核验记录保存在本批教师资料。

    参考程序(C++11)

    #include <bits/stdc++.h>
    using namespace std;
    long long gcdll(long long a,long long b){while(b){long long t=a%b;a=b;b=t;}return a;}
    int main(){ios::sync_with_stdio(false);cin.tie(nullptr);const int p=1143;
    string s;getline(cin,s);vector<string>words;string w;for(char c:s){if(isalpha((unsigned char)c))w+=c;else if(!w.empty()){words.push_back(w);w.clear();}}if(!w.empty())words.push_back(w);string hi=words[0],lo=words[0];for(string v:words){if(v.size()>hi.size())hi=v;if(v.size()<lo.size())lo=v;}cout<<hi;if(p==1143)cout<<"\n"<<lo;
    cout<<"\n";return 0;}
    
    • 1

    信息

    ID
    1011
    时间
    1000ms
    内存
    64MiB
    难度
    进阶
    标签
    递交数
    1
    已通过
    1
    上传者