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

Обсуждение задачи 1644. Куча орехов

WA 3 I dunno why all my tests works...
Послано Elmurod 25 окт 2008 18:39
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n,k,temp=100,temp1=100,need = 100,need1 = 100;
char s[15];
int asd = 0;
string s1;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> k >> s;
s1 = s;
if (s1 == "satisfied")
{
asd = 1;
if (n == 1)
{
cout << k;
exit(0);
}
temp = k;
if (temp < need)
need = temp;
}
if (s1 == "hungry")
{
temp1 = k;
if (temp1 < need1)
need1 = temp1;
}
}
if (asd == 1)
{
if (need >= need1)
cout<<need;
else if (need1 == 100) cout <<need;
else
cout<<"Inconsistent";
}
else<<"Inconsistent";
return 0;
}
Re: WA 3 I dunno why all my tests works...
Послано Asyamov Igor 25 окт 2008 18:42
try this test:
1)in: 0
  out: 10

2) in: 2
   3 hungry
   5 hungry

   out: 10
Re: WA 3 I dunno why all my tests works...
Послано Elmurod 25 окт 2008 19:10
thx for test i forgot this "Известно, что Попугай заведомо наестся десятью орехами и заведомо останется голодным, съев лишь два."
and change code
from

else
cout<<"Inconsistent";

to
else
cout<<"10";

but now have WA8 ////

can you show me better algorithm to solve this problem?
my mail : grumpy@doda.uz

Edited by author 25.10.2008 19:21

Edited by author 25.10.2008 19:21
Re: WA 3 I dunno why all my tests works...
Послано svr 25 окт 2008 20:01
try:
2
1 hungry
1 satysfied
Re: WA 3 I dunno why all my tests works...
Послано Asyamov Igor 25 окт 2008 20:29
your test is not correct!!!
may be you mean:
2
3 hungry
3 satysfied  ???
Re: WA 3 I dunno why all my tests works...
Послано Elmurod 25 окт 2008 20:56
test
2
1 hungry
1 satisfied

my solve show me answer 1
but it should be 10
because he will hungry even he eat 2

test
2
3 hungry
3 satisfied

answer 3 is it right?

Edited by author 25.10.2008 20:57

Edited by author 25.10.2008 21:00
Re: WA 3 I dunno why all my tests works...
Послано Asyamov Igor 25 окт 2008 20:59
right answer is: Inconsistent
Re: WA 3 I dunno why all my tests works...
Послано Elmurod 25 окт 2008 21:25
Igor Do you have ICQ? my number is 301-717-834
Re: WA 3 I dunno why all my tests works...
Послано Участник 25 окт 2008 21:39
Я думаю   1- голоден 1 - сыт... таких чисел не может быть по условию... сказано же от 3 до 9... Я все варианты перепробовал в том числе и свашими.. и все равно на 15 тесте ошибка...

Here is my code... Look at please.

Uses SysUtils;

var
  h: array [1..9] of byte;
  s: array [1..9] of byte;

  n,i: integer;
  min,max: integer;
  s1: string;
  ch: integer;
  ok: boolean;

begin
 //Assign(input,'input.txt'); reset(input);
 readln(n);
 min:=0;
 fillchar(h, sizeof(h),0);
 fillchar(s, sizeof(s),0);
 ok:=true;
 max:=100;
  for i:=1 to n do
   begin
     readln(s1);
     ch := strtoint(s1[1]);
     Delete(s1,1,2);
     if (s1 = 'hungry') then h[ch]:=1;
     if (s1 = 'satisfied') then begin s[ch]:=1;  ok:=false; end;
   end;
 if ok then begin writeln(10); exit; end;
 for i:=3 to 9 do
  begin
   if h[i]=1 then max:=i
    else
   if (s[i]=1) and ((min<max) and (max<100) or (min=0)) then min:=i;
  end;
  if (min = 0) and (max=100) then writeln('10')
  else
  if (min > max) or (max = 100) then writeln(min) else writeln('Inconsistent');
Re: WA 3 I dunno why all my tests works...
Послано svr 25 окт 2008 21:49
I made stupid mistake.
I meant
2
3 h
3 s
of course. This test I produced
when thinking about Wa8 and after got AC.
P.S.
I think you must be graitfull to us.
With our help you gone over Wa8.
Did you tried the text:
2
2 hungary
5 hungary
The answer is 10 because no information about satisfaction.



Edited by author 25.10.2008 22:23
WA#1
Послано Buni_Real 27 окт 2008 09:18
Elmurod misol to'g'ri yechdingma? 1-2  ta test ayt mening yechganimda 1-testdan qaytyapti my mail:bunyod-real@mail.ru
Re: WA#1
Послано Elmurod 27 окт 2008 13:42
Post there your code ... and we will try to help you ...
Re: WA 3 I dunno why all my tests works...
Послано svr 27 окт 2008 19:00
No, I made mistake again because bounds 3-9 to stochastic.
I meant about important test:
2
3 hung
5 hung
answer:10



Edited by author 27.10.2008 19:19
Re: WA 3 I dunno why all my tests works...
Послано Elmurod 27 окт 2008 20:03
if Hungry >= Satisfied answer will be "Inconsistent";
else min(Satisfied);
if no information about Satisfied then answer "10" thats all;