![]() |
1. Заголовок темы должен быть информативным. В противном случае тема удаляется ...
2. Все тексты программ должны помещаться в теги [code=pas] ... [/code].
3. Прежде чем задавать вопрос, см. "FAQ", если там не нашли ответа, воспользуйтесь ПОИСКОМ, возможно такую задачу уже решали!
4. Не предлагайте свои решения на других языках, кроме Паскаля (исключение - только с согласия модератора).
5. НЕ используйте форум для личного общения, все что не относится к обсуждению темы - на PM!
6. Одна тема - один вопрос (задача)
7. Проверяйте программы перед тем, как разместить их на форуме!!!
8. Спрашивайте и отвечайте четко и по существу!!!
![]() |
MaziF |
![]()
Сообщение
#1
|
Группа: Пользователи Сообщений: 2 Пол: Мужской Репутация: ![]() ![]() ![]() |
УСЛОВИЕ
Mr. F. wants to get a document be signed by a minister. A minister signs a document only if it is approved by his ministry. The ministry is an M-floor building with floors numbered from 1 to M, 1 ≤ M ≤ 100. Each floor has N rooms (1 ≤ N ≤ 500) also numbered from 1 to N. In each room there is one (and only one) official. A document is approved by the ministry only if it is signed by at least one official from the M-th floor. An official signs a document only if at least one of the following conditions is satisfied: the official works on the 1st floor; the document is signed by the official working in the room with the same number but situated one floor below; the document is signed by an official working in a neighbouring room (rooms are neighbouring if they are situated on the same floor and their numbers differ by one). Each official collects a fee for signing a document. The fee is a non-negative integer not exceeding 109. You should find the cheapest way to approve the document. Исходные данные The first line of an input contains two integers, separated by space. The first integer M represents the number of floors in the building, and the second integer N represents the number of rooms per floor. Each of the next M lines contains N integers separated with spaces that describe fees (the k-th integer at l-th line is the fee required by the official working in the k-th room at the l-th floor). Результат You should print the numbers of rooms in the order they should be visited to approve the document in the cheapest way. If there are more than one way leading to the cheapest cost you may print an any of them. ПРИМЕР 3 4 10 10 1 10 2 2 2 10 1 10 10 10 ОТВЕТ 3 3 2 1 1 я написал программу, которая правильно находит минимальную цену, но выводит не правильный путь не могу понять, где теряется правильный ![]() я вообще правильно решаю? program Project; Сообщение отредактировано: Lapp - 14.04.2009 9:09 |
![]() ![]() |
Lapp |
![]()
Сообщение
#2
|
![]() Уникум ![]() ![]() ![]() ![]() ![]() ![]() ![]() Группа: Модераторы Сообщений: 6 823 Пол: Мужской Реальное имя: Лопáрь (Андрей) Репутация: ![]() ![]() ![]() |
Если программа использует файл, то желательно прикладывать проверочный файл. Чтоб люди не мучились, создавая и пытаясь повторить твой результат. Если файл текстовый и не очень большой, то можно прямо в тексте.
-------------------- я - ветер, я северный холодный ветер
я час расставанья, я год возвращенья домой |
![]() ![]() |
![]() |
Текстовая версия | 18.07.2025 14:26 |