{"id":1225,"date":"2024-10-27T09:00:00","date_gmt":"2024-10-27T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1225"},"modified":"2024-09-30T11:11:42","modified_gmt":"2024-09-30T03:11:42","slug":"zerojudge-d575","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-d575\/","title":{"rendered":"ZeroJudge D575: End of the World"},"content":{"rendered":"<p class=\"translation-block\">According to legend, in the kingdom of \u201cBalabalabala\u201d (kingdom name), there once was a town named \u201cBalabalabala\u201d (town name) that was massacred. Later, a group of \u201cBalabalabala\u201d (possibly scientists or wizards) from the \u201cBalabalabala\u201d kingdom discovered that the massacre of the \u201cBalabalabala\u201d town was due to divine punishment. Interestingly, the scope of the judgment expanded in a cross-shaped pattern.<\/p>\n\n\n\n<p class=\"translation-block\">In a grid coordinate system (assuming the center square is at (0, 0), with right being (0, 1), up being (-1, 0), left being (0, -1), and down being (1, 0)), if the range is 1 and the center coordinate is (0, 0), then the scope of the divine judgment would cover the following grid, with the affected areas represented by \u25cf:\n<br>\u25cb\u25cb\u25cb\u25cb\u25cb<br>\u25cb\u25cb\u25cf\u25cb\u25cb<br>\u25cb\u25cf\u25cf\u25cf\u25cb<br>\u25cb\u25cb\u25cf\u25cb\u25cb<br>\u25cb\u25cb\u25cb\u25cb\u25cb<\/p>\n\n\n\n<p>Range 2<br>\u25cb\u25cb\u25cf\u25cb\u25cb<br>\u25cb\u25cf\u25cf\u25cf\u25cb<br>\u25cf\u25cf\u25cf\u25cf\u25cf<br>\u25cb\u25cf\u25cf\u25cf\u25cb<br>\u25cb\u25cb\u25cf\u25cb\u25cb<\/p>\n\n\n\n<p>Range 3<br>\u25cb\u25cb\u25cb\u25cf\u25cb\u25cb\u25cb<br>\u25cb\u25cb\u25cf\u25cf\u25cf\u25cb\u25cb<br>\u25cb\u25cf\u25cf\u25cf\u25cf\u25cf\u25cb<br>\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf<br>\u25cb\u25cf\u25cf\u25cf\u25cf\u25cf\u25cb<br>\u25cb\u25cb\u25cf\u25cf\u25cf\u25cb\u25cb<br>\u25cb\u25cb\u25cb\u25cf\u25cb\u25cb\u25cb<\/p>\n\n\n\n<p>Now, given the coordinates of the judgment\u2019s center, as well as the location of the \u201cBalabalabala\u201d kingdom\u2019s capital (city name: \u201cBalabalabala\u201d), and the range of the judgment, please determine whether the capital will be destroyed by the divine judgment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td class=\"translation-block\">Each test case consists of multiple test data points.\n<br>\nEach set of test data is provided in one line.\n<br>\nThe first and second numbers represent the coordinates of the divine judgment\u2019s center.\n<br>\nThe third and fourth numbers represent the coordinates of the kingdom\u2019s capital (all coordinate values are guaranteed to be between -2147483648 and 2147483647).\n<br>\nThe fifth number is the effective range r of the divine judgment (1 \u2264  r  \u2264 2147483647).<\/td><td>If the capital's coordinates fall within the range of divine judgment and are thus doomed to destruction, please output \"die\".<br>If the capital's coordinates are not within the range of divine judgment and thus escape destruction, please output \"alive\".<\/td><\/tr><tr><td>0 0 1 1 1<br>0 0 1 1 2<br>0 0 -1 2 3<br>-1 0 1 2 3<br>0 0 50 50 100<br>0 0 50 50 99<\/td><td>alive<br>die<br>die<br>alive<br>die<br>alive<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p>To calculate whether the city will be affected by divine judgment, compute the Manhattan distance between the city and the center of judgment. If the Manhattan distance is greater than the given range, the city will not be affected.<\/p>\n\n\n\n<p>Manhattan Distance: |x1 \u2013 x2| + |y1 \u2013 y2|<\/p>\n\n\n\n<p>It\u2019s important to declare the variables and the variables used to calculate the Manhattan distance as long long int.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=d575\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge D575: End of the World<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    long long int centerX, centerY, cityX, cityY, distance;\n    while (cin &gt;&gt; centerX &gt;&gt; centerY &gt;&gt; cityX &gt;&gt; cityY &gt;&gt; distance) {\n        const long long int manhattan = abs(centerX - cityX) + abs(centerY - cityY);\n        if (manhattan &gt; distance) {\n            cout &lt;&lt; &quot;alive\\n&quot;;\n        }\n        else cout &lt;&lt; &quot;die\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge D575\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u50b3\u8aaa\u5728\u300c\u5df4\u62c9\u5df4\u62c9\u5df4\u62c9\u300d(\u738b\u570b\u540d\u7a31) \u738b\u570b\u66fe\u7d93\u6709\u4e00\u500b\u88ab\u5c60\u6bba\u7684\u5c0f\u93ae\u53eb\u505a\u300c\u5df4\u62c9\u5df4\u62c9\u5df4\u62c9\u300d(\u5c0f\u93ae\u540d\u7a31)\u3002\u5f8c\u4f86\u300c\u5df4\u62c9\u5df4\u62c9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[6],"tags":[15,8,13],"class_list":["post-1225","post","type-post","status-publish","format-standard","hentry","category-6","tag-long-long-int","tag-8","tag-13"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=1225"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1225\/revisions"}],"predecessor-version":[{"id":1226,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1225\/revisions\/1226"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=1225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=1225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=1225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}