ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1496. Спамер

Wrong answer №7
Послано Grillepitch 20 авг 2011 02:09
#include <iostream>
#include <string>
using namespace std;
int main()
{
int N, counter = 0, p, g = 0;
cin >> N;
const int max = 128;
char ar[max][32] = {0};
char temp[max][32];
for ( int j = 0; j < N; ++j )
cin >> ar[j];
cout << endl;
for ( int j = 0; j < N - 1; ++j )
for ( int i = j + 1; i < N; ++i )
if ( strcmp ( ar[j], ar[i] ) == 0 )
{
    if ( counter > 0 )
    {
        for ( p = 1; p <= counter; ++p )
        {
            if ( strcmp ( ar[j], temp[p] ) == 0 )
                ++g;
        }
        if ( g == 0 )
        {
            strcpy ( temp[++counter], ar[j] );
            g = 0;
            break;
        }
    }
    else
    {
        strcpy ( temp[++counter], ar[j] );
        break;
    }
    break;
}
else
    continue;

    for ( int j = 1; j <= counter; ++j )
        cout << temp[j] << endl;
return 0;
}


Wrong answer. Test №7
Why ?

Edited by author 20.08.2011 02:09
Re: Wrong answer №7
Послано danon 7 окт 2011 17:29
Same. Give test, please.
Re: Wrong answer №7
Послано danon 7 окт 2011 20:05
My code [C#]:
using System;
using System.Text;
using System.Collections.Generic;

namespace _1820
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> spam = new List<string>();
            List<string> good = new List<string>();
            int n = Int32.Parse(Console.ReadLine());
            if (n <= 100)
            {
                int i, j, k;
                bool find = false;
                for (i = 0; i < n; i++)
                {
                    spam.Add(Console.ReadLine());
                }
                for (i = 0; i < spam.Count; i++)
                {
                    if (spam[i].Length <= 30)
                    {
                        for (j = i + 1; j < spam.Count; j++)
                        {
                            find = true;
                            if (spam[i] == spam[j])
                            {
                                if (good.Count > 0)
                                {
                                    for (k = 0; k < good.Count; k++)
                                    {
                                        if (good[k] == spam[j]) break;
                                        find = false;
                                    }
                                    if (!find) good.Add(spam[j]);
                                }
                                else
                                {
                                    good.Add(spam[i]);
                                    break;
                                }
                                break;
                            }
                        }
                    }
                }

                for (i = 0; i < good.Count; i++)
                {
                    Console.WriteLine(good[i]);
                }

            }
        }
    }
}