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

Shortest solution
Posted by Dranik 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;
}
Re: Shortest solution
Posted by Sandro (USU) 12 Jul 2011 13:30
Unfortunately, your solution has been rejudged. :) string.find() is too slow. Good luck!
Re: Shortest solution
Posted by Aditya Singh 9 Nov 2017 08:42
LOL