Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Прочее";
Текущий архив: 2006.11.05;
Скачать: [xml.tar.bz2];

Вниз

Задача с подготовки ACM   Найти похожие ветки 

 
Kair+ ©   (2006-10-18 07:27) [0]

Вобщем, задача с подготовки ACM - самая легкая, которую я не смог решить, т.е. не совсем чтобы не смог - код написать-то написал, только тестирующая система выдала Wrong Answer.
Код показывать пока не буду (чтобы свою мысль не навязывать), если кто-нибудь решит, то потом напишу для сравнения...

Problem C. Code Tanks
Hopefully yesterday you participated in the fascinating Code
Game Challenge event. And now you have a unique chance to
play on the side of the organizers team. You need to solve one of
the many challenging tasks organizers have met during the Code
Game Challenge preparation process.
The problem is the following. You are given the log of one match
with N tanks participating. The log is a sequence of successful
bullet shots, i.e. hits. Shots are listed in the log in the order of
the corresponding bullet hit the target tank as this happened in
the match. You need to calculate the number of hit points and
the score of each tank at the end of the match.
Here are the Code Game Challenge rules essential for this prob-lem:
² Each tank has 100 hit points and 0 score points at the be-ginning
of the match.
² Each shot always reduces the hit points of the target tank
by 8, and if the number of hit points of the target before
the shot was greater than zero, the shooting tank receives 3
score points.
² Only “active” tanks (with a positive number of hit points)
can shoot, so you can expect to find only shots fired by the
“active” tanks in the log .
² At the end of the match each tanks with positive hit points
additionally receive the number of score points equal to the
half of its hit points.

Input
The first line of the input contains two integer numbers N and
M (2 <= N <= 6; 1 <= M <= 4000), where N is the number of tanks
participating in the match and M is the number of shots fired.
The following M lines contain the descriptions of the shots. Each
description consists of two different integer numbers from 1 to N.
The first one is the number of the tank which fired the shot and
the second one is the number of the tank which was hit by the
shot.

Output
Write N lines to the output, one line for each tank, in the order
of the tank numbers. Write two integer numbers to each line —
the number of hit points and the number of score points of the
corresponding tank at the end of the match.

Example
input.txt
3 3
2 1
1 2
2 1
output.txt
84 45
92 52
100 50


 
КаПиБаРа ©   (2006-10-18 07:35) [1]

На русский то трудно перевести?


 
Loginov Dmitry ©   (2006-10-18 07:54) [2]

Все ломанулись решать задачу...


 
MeF Dei Corvi ©   (2006-10-18 08:02) [3]

А ограничения на память/время какие? Тупо промоделировать нельзя?


 
MBo ©   (2006-10-18 08:12) [4]

Это вовсе не олимпиадная задача.
Простой проход по списку выстрелов с выполнением заданных условий


 
Kair+ ©   (2006-10-18 12:55) [5]


> КаПиБаРа ©   (18.10.06 07:35) [1]
> На русский то трудно перевести?


Хотел чтобы в оригинале было. Потому, что я мог какую-нибудь деталь в условии задачи не заметить...


> MeF Dei Corvi ©   (18.10.06 08:02) [3]
> А ограничения на память/время какие?


2 сек, 64 Мб


> MBo ©   (18.10.06 08:12) [4]
> Это вовсе не олимпиадная задача.
> Простой проход по списку выстрелов с выполнением заданных
> условий


Ага, я сделал что-то вроде


var
 f: TextFile;
 i, m, n, x, y: Integer;
 a, b: array [1..6] of Integer;
begin
 AssignFile(f, "input.txt");
 Reset(f);
 Readln(f, n, m);
 for i := 1 to 6 do begin
   a[i] := 0; b[i] := 100; // начальные значения a - очки, b - жизнь
 end;
 for i := 1 to m do begin
   Readln(f, x, y);
   // тут еще можно поставить проверку на то, чтобы в мертвый танк не среляли (if b[y] > 0 then begin), но тоже выходит, что Wrong Answer
   Inc(a[x], 3); Dec(b[y], 8);
 end;
 CloseFile(f);
 AssignFile(f, "output.txt");
 Rewrite(f);
 for i := 1 to n do
   if b[i] > 0 then Writeln(f, b[i], b[i] div 2 + a[i])
     else Writeln(f, b[i], a[i]);
 CloseFile(f);
end;



Что тут не правильно?


 
default ©   (2006-10-18 13:25) [6]


>    // тут еще можно поставить проверку на то, чтобы в мертвый
> танк не среляли (if b[y] > 0

стрелять как раз в него могут только очки за это не начисляются, а вот жизнь мёртвого танка идёт в минус всё дальше


 
Ketmar ©   (2006-10-18 16:02) [7]

начисляются очки за попадание в мёртвый танк?


 
default ©   (2006-10-18 16:52) [8]

Ketmar ©   (18.10.06 16:02) [7]
у танка есть свойство - hit points(hp)
вначале hp равно 100 - танк бодрствует
когда по танку бабахают hp уменьшается на 8
когда hp становится 0 или меньше нуля - то танку капут
но по танку с неположительным hp всё ещё можно бабахать(хоть он уже мёртв) - очки за это не дают(как в противоположном случае), но вот hp уменьшается на 8 как когда он был жив(то есть идёт порча уже мёртвого танка:))
душераздирающая история про танки, правда?

вот автор сабжа похоже не учёл, что hp при попаданий в мёртвый танк продолжает уменьшаться на 8


 
Ketmar ©   (2006-10-18 16:57) [9]

я прочёл задание. %-) вот и говорю, что автор не учёл попадания в мёртвый танк. то же самое, что ты сказал. %-)


 
default ©   (2006-10-18 17:15) [10]

Ketmar ©   (18.10.06 16:57) [9]
если бы вместо очки ты написал хинты:)


 
Kair+ ©   (2006-10-18 20:35) [11]

Мда... теперь Accepted... Почему я такой невнимательный...

Ладно, спасибо вам за помощь.



Страницы: 1 вся ветка

Форум: "Прочее";
Текущий архив: 2006.11.05;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.48 MB
Время: 0.046 c
15-1160644674
DelphiLexx
2006-10-12 13:17
2006.11.05
ToolBar2000+TBX


15-1161064558
palva
2006-10-17 09:55
2006.11.05
Еще раз про пончик


2-1161598700
id
2006-10-23 14:18
2006.11.05
Вычисления значения функции.


8-1143547847
kmi
2006-03-28 16:10
2006.11.05
Как изменить бинарный файл?


2-1161184107
Tbegin
2006-10-18 19:08
2006.11.05
моя первая прога





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский