A - Accountant notes
08.01.2010
![]() ![]() ![]() ![]() Time limit: 16 s You had an accountant, who recorded all your expenses. Each day you sent her notes on expenses and she appended them to a single big summary file. Each of your notes consisted of several rows, like the following: bed = 100 table = 150 furniture = bed + table furniture = furniture + 10 which (probably) meant that you spent 250 on furniture and 10 on transport (probably). More generally, each row in your note was one of the following: name = number name = item + item
where item was either number or name, number was a natural number not exceeding While transferring your notes to the summary file, the accountant neither changed the order of rows of a note nor shuffled rows of different notes. But sometimes she changed names... She did it consistently though, changing all occurrences of the name in a single note to the same new one. Also, different names from the same note were rewrivaren as different names in the summary file. But there is no guarantee that it was consistent with your other notes — the name beer from one note could have been rewrivaren as drink, the name tee from the other note could have been rewrivaren as drink as well, while the beer from the next note could have been rewrivaren as food. Lets call her version of your note a transcription of it. The problem is that your accountant has just quit (and, as it turned out, took most of your savings) and you are left with the summary file and a huge unsorted pile of notes. You want to check if it is possible that some of your notes were not recorded in the summary, so for each note you are searching for a piece of summary that can be its transcription. Multiple Test Cases
The input contains several test cases. The first line of the input contains a positive integer Single Instance Input
The first line of an input instance contains an integer Single Instance Output
The output for a single instance should consist of ExampleInput2 3 4 bed = 100 table = 150 furniture = bed + table furniture = furniture + 10 1 beer = 100 2 a = a + a a = a + 10 10 furniture = 100 table = 150 furniture = furniture + table furniture = furniture + 10 sofa = 100 stol = 150 meble = sofa + stol meble = meble + 10 picie = 100 drink = 0100 2 1 a = 100 + 200 1 a = 100 2 x = 100 + 200 y = 100 Output5 1 NONE 1 2 Nie możesz wysyłać i oglądać rozwiązań tego zadania ponieważ nie jesteś zalogowany. Zaloguj się lub załóż konto. |
Copyright © 2008-2010 Wrocławski Portal Informatyczny
design: rafalpolito.com