2 solutions

  • 2
    @ 2024-8-7 18:08:28
    #include <bits/stdc++.h>
    using namespace std;
    int main() {
    	string s, c;
    	cin >> c;
    	getchar();
    	getline(cin, s);
    	for (int i = 0; i < c.size(); i++) {
    		c[i] = tolower(c[i]);
    	}
    	for (int i = 0; i < s.size(); i++) {
    		s[i] = tolower(s[i]);
    	}
    	c = ' ' + c + ' ';
    	s = ' ' + s + ' ';
    	if (s.find(c) == string::npos) {
    		cout << "-1";
    		return 0;
    	}
    	int firstpos = s.find(c);
    	int pos = firstpos;
    	int ans = 0;
    	while (pos != string::npos) {
    		ans++;
    		pos = s.find(c, pos + 1);
    	}
    	cout << ans << " " << firstpos;
    	return 0;
    }
    

    Information

    ID
    449
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    61
    Accepted
    14
    Uploaded By