1 条题解

  • 1
    @ 2025-07-19 14:26:38

    链接

    单词统计(oi00002)

    引用题解


    感谢雷倚鸣分享的题解

    AC代码:

    #include<bits/stdc++.h>
    using namespace std;
    string t;
    void Dx()
    {
        for(int j=0;j<t.size();j++)
        {
            if(t[j]>=65&&t[j]<=90)
            {
                t[j]=char(t[j]+32);
            }
        }
        //cout<<a[s];
    }
    int main()
    {
    
        map<string,int> a;
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            string c;
            cin>>c;
            int b=0;
            for(int k=0;k<c.size();k++)
            {
                if(c[k]==',')
                {
                    t="";
                    t=c.substr(b,k-b);
                    Dx();
                    a[t]++;
                    b=k+1;
                }
            }
            t="";
            t=c.substr(b,c.size()-b);
            Dx();
            a[t]++;
        }
        int sum=0;
        
        for(map<string,int>::iterator it=a.begin();it!=a.end();it++)
        {
            //cout<<it->first<<endl;
            sum++;
        }
        cout<<sum;//<<a["dsa"];
    }
    /*
    4
    ad,da,ds,dsa
    das,ds,sa,dsaf,ads
    dsa,asd,ffdsa,sasd,fdsa,fdsa,sdf
    dsa,fdsaf,dsa,dsa,dssa,dsa
    */
    
  • 1

信息

ID
1001
难度
9
分类
(无)
标签
(无)
递交数
4
已通过
1
通过率
25%
上传者