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 1573. Alchemy

why i got wa6!!
Posted by Time-warren258 18 Aug 2009 09:13
here my code:
#include<iostream>
using namespace std;
int main()
{
    int flag[3];
    int b,r,y;
    cin>>b>>r>>y;
    int n,i,j,k;
    char str[3][10];
    cin>>n;
    i=0;
    while(i<n)
        cin>>str[i++];
    for(i=0;i<n;i++)
    {
        if(str[i][0]=='B'||str[i][0]=='b')
            flag[0]=1;
        if(str[i][0]=='R'||str[i][0]=='r')
            flag[1]=1;
        if(str[i][0]=='Y'||str[i][0]=='y')
            flag[2]=1;
    }
    int sum=1;
    if(flag[0]==1)
        sum*=b;
    if(flag[1]==1)
        sum*=r;
    if(flag[2]==1)
        sum*=y;
    cout<<sum<<endl;
    return 0;
}

can anybody help me???
Re: why i got wa6!!
Posted by Sergey Lazarev (MSU Tashkent) 18 Aug 2009 12:21
You didn't initialized "flag" and it contains random values.
Re: why i got wa6!!
Posted by Time-warren258 18 Aug 2009 16:08
thanks,after i change "flag[3]=0;",i got a AC!