{"id":329,"date":"2013-08-02T21:58:54","date_gmt":"2013-08-03T01:58:54","guid":{"rendered":"http:\/\/www.ferociouscoder.com\/blog\/?p=329"},"modified":"2013-08-02T22:18:01","modified_gmt":"2013-08-03T02:18:01","slug":"uva-278-chess","status":"publish","type":"post","link":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html","title":{"rendered":"UVA 278 &#8211; Chess"},"content":{"rendered":"<p>Pretty easy problem. Kings, Queens and Rooks are easy; with Knights you need to realize that knigns basically attack boxes of the opposite color. Once you figure that out, you are golden.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nimport java.io.PrintWriter;\r\nimport java.util.Scanner;\r\n\r\n\/**\r\n * \r\n * @author Sanchit M. Bhatnagar\r\n * @see http:\/\/uhunt.felix-halim.net\/id\/74004\r\n * \r\n *\/\r\npublic class P278 {\r\n\r\n  public static void main(String&#x5B;] args) {\r\n    Scanner sc = new Scanner(System.in);\r\n    PrintWriter out = new PrintWriter(System.out);\r\n\r\n    int N = sc.nextInt();\r\n    for (int zz = 0; zz &amp;lt; N; zz++) {\r\n      String type = sc.next();\r\n      int R = sc.nextInt();\r\n      int C = sc.nextInt();\r\n      int min = Math.min(R, C);\r\n      int max = Math.max(R, C);\r\n      if (type.equals(&amp;quot;r&amp;quot;) || type.equals(&amp;quot;Q&amp;quot;)) {\r\n        out.println(min);\r\n      } else if (type.equals(&amp;quot;k&amp;quot;)) {\r\n        int a = max \/ 2;\r\n        int b = (max - a);\r\n        int c = min \/ 2;\r\n        int d = (min - c);\r\n        out.println(Math.max(a * c + b * d, a * d + b * c));\r\n      } else if (type.equals(&amp;quot;K&amp;quot;)) {\r\n        out.println(((max + 1) \/ 2) * ((min + 1) \/ 2));\r\n      }\r\n    }\r\n\r\n    out.close();\r\n    sc.close();\r\n  }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Pretty easy problem. Kings, Queens and Rooks are easy; with Knights you need to realize that knigns basically attack boxes of the opposite color. Once you figure that out, you are golden. import java.io.PrintWriter; import java.util.Scanner; \/** * * @author Sanchit M. Bhatnagar * @see http:\/\/uhunt.felix-halim.net\/id\/74004 * *\/ public class P278 { public static void &hellip; <a href=\"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">UVA 278 &#8211; Chess<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,19,17],"tags":[21,20,22],"class_list":["post-329","post","type-post","status-publish","format-standard","hentry","category-competitive-programming-3","category-java","category-uva-online-judge","tag-competitive-programming-3-2","tag-java-2","tag-uva-online-judge-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>UVA 278 - Chess - Ferocious Coder<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UVA 278 - Chess - Ferocious Coder\" \/>\n<meta property=\"og:description\" content=\"Pretty easy problem. Kings, Queens and Rooks are easy; with Knights you need to realize that knigns basically attack boxes of the opposite color. Once you figure that out, you are golden. import java.io.PrintWriter; import java.util.Scanner; \/** * * @author Sanchit M. Bhatnagar * @see http:\/\/uhunt.felix-halim.net\/id\/74004 * *\/ public class P278 { public static void &hellip; Continue reading UVA 278 &#8211; Chess &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html\" \/>\n<meta property=\"og:site_name\" content=\"Ferocious Coder\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-03T01:58:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-08-03T02:18:01+00:00\" \/>\n<meta name=\"author\" content=\"Rawrosaur\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rawrosaur\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html\"},\"author\":{\"name\":\"Rawrosaur\",\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/#\\\/schema\\\/person\\\/1fb5cbee546cffd619a7b301e3dc447a\"},\"headline\":\"UVA 278 &#8211; Chess\",\"datePublished\":\"2013-08-03T01:58:54+00:00\",\"dateModified\":\"2013-08-03T02:18:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html\"},\"wordCount\":184,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/#\\\/schema\\\/person\\\/1fb5cbee546cffd619a7b301e3dc447a\"},\"keywords\":[\"competitive programming 3\",\"java\",\"uva online judge\"],\"articleSection\":[\"Competitive Programming 3\",\"Java\",\"UVA Online Judge\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html\",\"url\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html\",\"name\":\"UVA 278 - Chess - Ferocious Coder\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/#website\"},\"datePublished\":\"2013-08-03T01:58:54+00:00\",\"dateModified\":\"2013-08-03T02:18:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/uva-278-chess-329.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UVA 278 &#8211; Chess\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/\",\"name\":\"Ferocious Coder\",\"description\":\"RAWR!\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/#\\\/schema\\\/person\\\/1fb5cbee546cffd619a7b301e3dc447a\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/#\\\/schema\\\/person\\\/1fb5cbee546cffd619a7b301e3dc447a\",\"name\":\"Rawrosaur\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg\",\"caption\":\"Rawrosaur\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg\"},\"sameAs\":[\"http:\\\/\\\/www.ferociouscoder.com\\\/\"],\"url\":\"https:\\\/\\\/www.ferociouscoder.com\\\/blog\\\/archives\\\/author\\\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UVA 278 - Chess - Ferocious Coder","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html","og_locale":"en_US","og_type":"article","og_title":"UVA 278 - Chess - Ferocious Coder","og_description":"Pretty easy problem. Kings, Queens and Rooks are easy; with Knights you need to realize that knigns basically attack boxes of the opposite color. Once you figure that out, you are golden. import java.io.PrintWriter; import java.util.Scanner; \/** * * @author Sanchit M. Bhatnagar * @see http:\/\/uhunt.felix-halim.net\/id\/74004 * *\/ public class P278 { public static void &hellip; Continue reading UVA 278 &#8211; Chess &rarr;","og_url":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html","og_site_name":"Ferocious Coder","article_published_time":"2013-08-03T01:58:54+00:00","article_modified_time":"2013-08-03T02:18:01+00:00","author":"Rawrosaur","twitter_misc":{"Written by":"Rawrosaur","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html#article","isPartOf":{"@id":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html"},"author":{"name":"Rawrosaur","@id":"https:\/\/www.ferociouscoder.com\/blog\/#\/schema\/person\/1fb5cbee546cffd619a7b301e3dc447a"},"headline":"UVA 278 &#8211; Chess","datePublished":"2013-08-03T01:58:54+00:00","dateModified":"2013-08-03T02:18:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html"},"wordCount":184,"commentCount":3,"publisher":{"@id":"https:\/\/www.ferociouscoder.com\/blog\/#\/schema\/person\/1fb5cbee546cffd619a7b301e3dc447a"},"keywords":["competitive programming 3","java","uva online judge"],"articleSection":["Competitive Programming 3","Java","UVA Online Judge"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html","url":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html","name":"UVA 278 - Chess - Ferocious Coder","isPartOf":{"@id":"https:\/\/www.ferociouscoder.com\/blog\/#website"},"datePublished":"2013-08-03T01:58:54+00:00","dateModified":"2013-08-03T02:18:01+00:00","breadcrumb":{"@id":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ferociouscoder.com\/blog\/archives\/uva-278-chess-329.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.ferociouscoder.com\/blog"},{"@type":"ListItem","position":2,"name":"UVA 278 &#8211; Chess"}]},{"@type":"WebSite","@id":"https:\/\/www.ferociouscoder.com\/blog\/#website","url":"https:\/\/www.ferociouscoder.com\/blog\/","name":"Ferocious Coder","description":"RAWR!","publisher":{"@id":"https:\/\/www.ferociouscoder.com\/blog\/#\/schema\/person\/1fb5cbee546cffd619a7b301e3dc447a"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.ferociouscoder.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.ferociouscoder.com\/blog\/#\/schema\/person\/1fb5cbee546cffd619a7b301e3dc447a","name":"Rawrosaur","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg","caption":"Rawrosaur"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/1372156bd3b16de375c8727c2c617467bf6ff38f1679a7912f48286349c17e96?s=96&d=retro&r=pg"},"sameAs":["http:\/\/www.ferociouscoder.com\/"],"url":"https:\/\/www.ferociouscoder.com\/blog\/archives\/author\/admin"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1mYMV-5j","jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/posts\/329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/comments?post=329"}],"version-history":[{"count":2,"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/posts\/329\/revisions\/333"}],"wp:attachment":[{"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/media?parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/categories?post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ferociouscoder.com\/blog\/wp-json\/wp\/v2\/tags?post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}