1 条题解

  • 1
    @ 2024-11-7 17:04:57
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string l, p, p1;
        cin >> l;
    	for(int i = 0; i < l.size(); ++ i) l[i] = tolower(l[i]);
     	getline(cin, p1);
    	getline(cin, p);
    	string t = "";
    	int pos = 0, cnt = 0;
    	map<string,int> mp;
    	for(int i = 0; i < p.size(); ++ i)
    	{
    		if(p[i] != ' ') t += tolower(p[i]);
    		else
    		{
    			if(t == l)
    			{
    				pos = cnt;
    				break;
    			}
    			cnt ++;
    			t = "";
    			continue;
    		}
    	}
    	if(t == l)
    	{
    		pos = cnt;
    	}
    	t = "";
        for(int i = 0; i < p.size(); ++ i)
    	{
    		if(p[i] != ' ') t += tolower(p[i]);
    		else
    		{
    			mp[t] ++;
    			t = "";
    		}
    	}
    	mp[t] ++; t = "";
    	
    	if(mp[l]) cout << mp[l] << ' ' << pos << endl;
    	else cout << -1 << endl;
        return 0;
    }
    
    • 1

    信息

    ID
    5468
    时间
    1000ms
    内存
    256MiB
    难度
    3
    标签
    递交数
    2
    已通过
    1
    上传者