{"id":17446165,"url":"https://github.com/markus1189/emperor-escape","last_synced_at":"2025-03-28T03:28:52.425Z","repository":{"id":16016020,"uuid":"18759552","full_name":"markus1189/emperor-escape","owner":"markus1189","description":null,"archived":false,"fork":false,"pushed_at":"2014-04-14T12:33:10.000Z","size":160,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-02T04:44:00.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markus1189.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-14T12:20:28.000Z","updated_at":"2019-12-05T06:33:21.000Z","dependencies_parsed_at":"2022-08-04T07:30:32.019Z","dependency_job_id":null,"html_url":"https://github.com/markus1189/emperor-escape","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markus1189%2Femperor-escape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markus1189%2Femperor-escape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markus1189%2Femperor-escape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markus1189%2Femperor-escape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markus1189","download_url":"https://codeload.github.com/markus1189/emperor-escape/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245965886,"owners_count":20701738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-17T18:22:46.392Z","updated_at":"2025-03-28T03:28:52.403Z","avatar_url":"https://github.com/markus1189.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Escape - [Source](https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge\u0026Itemid=8\u0026category=610\u0026page=show_problem\u0026problem=4595) ###\n\nAfter an epic fight with the emperor lich, the hero struggles to\nescape the dungeon consisting of `n` chambers and `n−1` corridors\nconnecting them.\n\nHe starts in chamber number `1` and must reach chamber number `t`,\nmoving only along the corridors.  All chambers are reachable from\nchamber number `1`.\n\nBruised after the last fight, the hero starts the journey with `0`\nhit-points (HP).  These points represent his health - if ever they\nfall below zero, the hero’s story ends there as a tragic one.\n\nIn some chambers there are monsters - a monster must be fought, and it\nalways manages to take some of the hero’s HP.  In some other chambers\nthere are magic pools - every pool restores some number of the\nhit-points.\n\nThere is no upper limit on the hero’s health.  Every chamber can be\nvisited multiple times, but the gain or loss of HP happens only once,\non the very first visit.\n\nDetermine whether the hero can escape the dungeon alive.\n\n#### Input ####\n\nThe first line of input contains the number of test cases `T`.\n\nThe descriptions of the test cases follow:\n\nThe first line of each test case contains two integers: the number of\nchambers `n`, `2 \u003c= n \u003c= 200000`, and the number of the exit chamber\n`t`, `2 \u003c= t \u003c= n`.\n\nThe second line contains `n` space separated integers between `−10^6`\nand `10^6` - the i-th of them denotes the HP gain in the i-th chamber\n(negative denotes a monster, positive - a pool, and zero means that\nthe chamber is empty).  The first chamber does not contain a monster,\nbut a pool is possible there.  The exit chamber may contain a pool or\na monster, and the monster will have to be fought before escaping.\n\nThe next `n−1` lines contain the descriptions of corridors.  Each one\ncontains a pair of integers - the ends of a corridor.\n\n#### Output ####\n\nFor each test case print a single line containing the word ‘escaped’\nif escape is possible, or ‘trapped’ otherwise.\n\nSample Input\n```\n2\n7 7\n0 -3 2 2 3 -4 0\n1 2\n2 3\n2 4\n1 5\n5 6\n6 7\n3 2\n3 3 -4\n1 3\n2 3\n```\n\nSample Output\n```\nescaped\ntrapped\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkus1189%2Femperor-escape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkus1189%2Femperor-escape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkus1189%2Femperor-escape/lists"}