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 1737. Mnemonics and Palindromes 3

wa #8 helppppppp pls
Posted by h1ci 24 Nov 2009 21:33
whats test 8
or whats wrong with that:
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char a[3]={'a','b','c'};
    if(n*6>10000){ cout<<"TOO LONG" << endl; return 0;}
    if(n==1){ cout << "a\nb\nc\n"; return 0;}
    for(int i=0; i<n; i++)
    {
            cout << a[i%3];
    }
    cout << endl;
    a[0]='a'; a[1]='c'; a[2]='b';
    //////////////////////////////
    for(int i=0; i<n; i++)
    {
            cout << a[i%3];
    }
    cout << endl;
    a[0]='b'; a[1]='a'; a[2]='c';
    //////////////////////////////
    for(int i=0; i<n; i++)
    {
            cout << a[i%3];
    }
    cout << endl;
    a[0]='b'; a[1]='c'; a[2]='a';
    //////////////////////////////
    for(int i=0; i<n; i++)
    {
            cout << a[i%3];
    }
    cout << endl;
    a[0]='c'; a[1]='a'; a[2]='b';
    //////////////////////////////
    for(int i=0; i<n; i++)
    {
            cout << a[i%3];
    }
    cout << endl;
    a[0]='c'; a[1]='b'; a[2]='a';
    //////////////////////////////
    for(int i=0; i<n; i++)
    {
            cout << a[i%3];
    }
    cout << endl;
    return 0;
}
Re: wa #8 helppppppp pls
Posted by unlucky [Vologda SPU] 24 Nov 2009 23:33
Your problem is that line -
h1ci wrote 24 November 2009 21:33
    if(n*6>10000){ cout<<"TOO LONG" << endl; return 0;}
}
Re: wa #8 helppppppp pls
Posted by h1ci 25 Nov 2009 16:29
whats wrong with that? If the output exceeds 10000 letters output "TOO LONG" ?!?!
Re: wa #8 helppppppp pls
Posted by h1ci 25 Nov 2009 16:31
Oh, sorry my bad it's 100 000 not 10 000; AC now



Edited by author 25.11.2009 16:33

Edited by author 25.11.2009 16:33

Edited by author 25.11.2009 16:33

Edited by author 25.11.2009 16:33

Edited by author 25.11.2009 16:33
STL is your friend (+)
Posted by ASK 4 Apr 2010 18:47
Btw, instead of copy/pasting code for every permutation you can

    char a[] = "abc";
    do{
      F(i,n) cout << a[i%3]; cout << endl;
    }while(next_permutation(a,a+3));

where F is
#define F(i,n) for(int i = 0; i < n; ++i)