ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1423. String Tale

Dranik Shortest solution [2] // Problem 1423. String Tale 10 Jul 2011 22:07
int main()
{
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;
    s1 += s1;
    int pos = (int) s1.find(s2);
    switch ( pos )
    {
    case -1:
        cout << -1;
        break;
    case 0:
        cout << 0;
        break;
    default:
        cout << n-pos;
    }
    return 0;
}
Sandro (USU) Re: Shortest solution [1] // Problem 1423. String Tale 12 Jul 2011 13:30
Unfortunately, your solution has been rejudged. :) string.find() is too slow. Good luck!
Aditya Singh Re: Shortest solution // Problem 1423. String Tale 9 Nov 2017 08:42
LOL