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 1219. Symbolic Sequence

Why WA 1 I've counted 'a','ab','abc' and other subsequences and got satisfying to condition....
Posted by IlushaMax 6 Apr 2017 01:17
#include <bits/stdc++.h>
using namespace std;

int main() {
    string letter="abcdefghijklmnopqrstuvwxyz";
    int k=letter.size();
    int i1,i2,i3;
    string part,bigpart;
    for(i1=0;i1<k;i1++)
    {
        for(i2=0;i2<k;i2++)
        {
            for (i3=0;i3<k;i3++)
            {
                part="";
                part.pb(letter[i1]);
                if(part[0]!=letter[i2]) part.pb(letter[i2]); else continue;
                if(part[0]!=letter[i3]&&part[1]!=letter[i3]) part.pb(letter[i3]); else continue;
                bigpart.pb(letter[i1]);bigpart.pb(letter[i2]);bigpart.pb(letter[i3]);
            }
        }
    }
    string ans="";
    //cout<<bigpart.size()/3;
    while(ans.size()<1000000)
    {
        ans=ans+bigpart;
    }
    /*for (int i=0;i<1000000;i++)
    {
        cout<<ans[i];
    }*/
    int res=0;
    for (int i=0;i<1000000;i++)
    {
        if (ans.substr(i,1)=="a") res++;
    }
    cout<<res;
    return 0;
}

Maybe 1 test is a sort of tricky?

Edited by author 06.04.2017 01:18