{"id":308,"date":"2018-11-01T19:31:20","date_gmt":"2018-11-01T11:31:20","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=308"},"modified":"2018-11-01T19:32:02","modified_gmt":"2018-11-01T11:32:02","slug":"lp4578-fjoi2018-%e6%89%80%e7%bd%97%e9%97%a8%e7%8e%8b%e7%9a%84%e5%ae%9d%e8%97%8f","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2018\/11\/01\/lp4578-fjoi2018-%e6%89%80%e7%bd%97%e9%97%a8%e7%8e%8b%e7%9a%84%e5%ae%9d%e8%97%8f\/","title":{"rendered":"lp4578 FJOI2018 \u6240\u7f57\u95e8\u738b\u7684\u5b9d\u85cf"},"content":{"rendered":"<p>\u9996\u5148\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\uff0c\u4ee4\u6bcf\u4e00\u884c\u3001\u5217\u6570\u5b57\u7684\u53d8\u5316\u4e3a\\(dx_{i},dy_{i}\\)\uff0c\u90a3\u4e48\u5bf9\u4e8e\\(z_{i,j}\\)\uff0c\u4e00\u5b9a\u6709\uff1a<br \/>\n$$dx_{i}+dy_{j}=z_{i,j}$$<br \/>\n\u5bf9\u8fd9\u4e2a\u7ebf\u6027\u65b9\u7a0b\u7ec4\u53d8\u5f62\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u5982\u679c\u6307\u5b9a\u5e8f\u5217\u5408\u6cd5\uff0c\u90a3\u4e48\uff1a<br \/>\n$$ \\forall x ,z_{x,j_{1}}-z_{x,j_{2}}=dy_{j_{1}}-dy_{j_{2}} $$<br \/>\n$$ \\forall y ,z_{i_{1},y}-z_{i_{2},y}=dx_{i_{1}}-dx_{i_{2}} $$<br \/>\n\u800c\uff0c\u5f53\\(dx\\)\u548c\\(dy\\)\u7684\u76f8\u5bf9\u5173\u7cfb\u4e0d\u77db\u76fe\u65f6\uff0c\u4e00\u5b9a\u53ef\u4ee5\u5bfc\u51fa\u4e00\u4e2a\u7b26\u5408\u9898\u610f\u7684\u77e9\u9635\u3002<br \/>\n\u56e0\u6b64\uff0c\u6211\u4eec\u5bf9\u4e8e\u6bcf\u7ec4\\(x,y\\)\uff0c\u7edf\u8ba1\u5b83\u4eec\u7684\u76f8\u5bf9\u5173\u7cfb\u5373\u53ef\u3002<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\nusing namespace std;\r\nint n,m,k; \r\nint dx[1005][1005],dy[1005][1005];\r\nbool visx[1005][1005],visy[1005][1005];\r\nint x[1005],y[1005],z[1005];\r\nvoid init(){\r\n    memset(dx,0,sizeof(dx));\r\n    memset(dy,0,sizeof(dy));\r\n    memset(visx,0,sizeof(visx));\r\n    memset(visy,0,sizeof(visy));\r\n    scanf(\"%d%d%d\",&amp;n,&amp;m,&amp;k);\r\n    for(int i=1;i&lt;=k;++i){\r\n        scanf(\"%d%d%d\",&amp;x[i],&amp;y[i],&amp;z[i]);\r\n    }\r\n    int nw;\r\n    for(int i=1;i&lt;k;++i){\r\n        for(int j=i+1;j&lt;=k;++j){\r\n            if(x[i]==x[j]&amp;&amp;y[i]==y[j]&amp;&amp;z[i]!=z[j]){\r\n                puts(\"No\");\r\n                return; \r\n            }\r\n            if(x[i]==x[j]){\r\n                nw=y[i]&gt;y[j]?z[j]-z[i]:z[i]-z[j];\r\n                if(visx[y[i]][y[j]]&amp;&amp;dx[y[i]][y[j]]!=nw){\r\n                    puts(\"No\");\r\n                    return;\r\n                }\r\n                dx[y[i]][y[j]]=dx[y[j]][y[i]]=nw;\r\n                visx[y[i]][y[j]]=visx[y[j]][y[i]]=1; \r\n            }\r\n            if(y[i]==y[j]){\r\n                nw=x[i]&gt;x[j]?z[j]-z[i]:z[i]-z[j];\r\n                if(visy[x[i]][x[j]]&amp;&amp;dy[x[i]][x[j]]!=nw){\r\n                    puts(\"No\");\r\n                    return;\r\n                }\r\n                dy[x[i]][x[j]]=dy[x[j]][x[i]]=nw;\r\n                visy[x[i]][x[j]]=visy[x[j]][x[i]]=1; \r\n            }\r\n        }\r\n    }\r\n    for(int i=1;i&lt;=n;++i){\r\n        if(dx[i][i]||dy[i][i]){\r\n            puts(\"No\");\r\n            return;\r\n        }\r\n    }\r\n    puts(\"Yes\");\r\n}\r\nint main(){\r\n    int T;\r\n    scanf(\"%d\",&amp;T);\r\n    while(T--){\r\n        init();\r\n    }\r\n    return 0;\r\n} <\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\uff0c\u6211\u4eec\u53ef\u4ee5\u77e5\u9053\uff0c\u4ee4\u6bcf\u4e00\u884c\u3001\u5217\u6570\u5b57\u7684\u53d8\u5316\u4e3a\\(dx_{i},dy_{i}\\)\uff0c\u90a3\u4e48\u5bf9\u4e8e\\(z_{i,j}\\) &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2018\/11\/01\/lp4578-fjoi2018-%e6%89%80%e7%bd%97%e9%97%a8%e7%8e%8b%e7%9a%84%e5%ae%9d%e8%97%8f\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp4578 FJOI2018 \u6240\u7f57\u95e8\u738b\u7684\u5b9d\u85cf\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[35,24,38,8,9,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/308"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":309,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/308\/revisions\/309"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}