1 solutions

  • 1
    @ 2025-1-17 17:05:17

    34行,洒洒水啦

    #include <bits/stdc++.h>
    using namespace std;
    map<string,int> mp;
    bool check(char c){
    	if(isdigit(c))return 1;
    	if('a'<=c && c<='z')return 1;
    	if('A'<=c && c<+'Z')return 1;
    	return 0;
    }
    int main(){
    	string s = "",maxstr;
    	int ans = 0;
    	char c;
    	while(c = getchar()){
    		if(c == '\n')break;
    		if(check(c)){
    			if('A'<=c && c<='Z')c = c-'A'+'a';
    			s+=c;
    		}
    		else {
    			if(!s.size())continue;
    			mp[s]++;
    			if(mp[s]>ans){
    				ans = mp[s];
    				maxstr = s;
    			}
    			else if(mp[s] == ans && maxstr>s)maxstr = s;
    			s = "";
    		}
    	}
    	cout<<maxstr;
    	printf(" %d",ans);
    	return 0;
    }
    
    • 1

    Information

    ID
    689
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    (None)
    # Submissions
    12
    Accepted
    4
    Uploaded By