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 1563. Bayan

WA 1... What's wrong?
Posted by Drema [KhAI] Tihov Ilya 30 May 2009 10:37
#include <stdlib.h>
#include <iostream>
using namespace std;

int main()
{
    int n, cnt = 0;
    register int j;
    char shop[1001][31];
    char used[5] = "stop";

    cin >> n;
    for(register int i = 0; i < n; i++)
        cin >> shop[i];

    for(register int i = 0; i < n; i++)
    {
        if(shop[i] == "stop")
            break;
        for(j = i + 1; j <= n; j++)
        {
            if(strcmp(shop[j], "stop") != 0)
                if(strcmp(shop[i], shop[j]) == 0)
                {
                    cnt++;
                    strcpy(shop[j], "stop");
                }
        }
    }

    cout << cnt;
}
WA 1
Posted by Tolya_wolf 20 Jan 2010 11:11
The same problem:
#include <stdio.h>
#include <string.h>

void main(void)
{
    char n[1000][31]={'/'};
    int i,y,qw,bayan=0;

    scanf("%d",&qw);

    for(i=0;i<qw;i++)
    {    scanf("%s",&n[i][0]);
        for(y=0;y<=i-1;y++)
            if(strcmp(n[y],n[i])==0)
            {    n[y][0]='/';
                bayan++;}
    }
    printf("%d",bayan);
}

Edited by author 20.01.2010 11:12

Edited by author 20.01.2010 11:12
Re: WA 1
Posted by Sergey Lazarev (MSU Tashkent) 20 Jan 2010 12:30
"The brands are the strings of Latin letters and blanks"!
scanf doesn't read blanks ("aaa bbb" - two words for scanf).
Re: WA 1
Posted by DNS 15 May 2010 01:58
I use

getline(cin,str); // !!!
     for(int i=0; i<n;i++){getline(cin,str)...

and Accepted.