{"id":705,"date":"2019-09-29T12:07:53","date_gmt":"2019-09-29T04:07:53","guid":{"rendered":"http:\/\/fankasy.xyz\/?p=705"},"modified":"2019-10-01T21:14:40","modified_gmt":"2019-10-01T13:14:40","slug":"noj1025-01%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"http:\/\/fankasy.xyz\/index.php\/2019\/09\/29\/noj1025-01%e6%8e%92%e5%ba%8f\/","title":{"rendered":"NOJ1024  01\u6392\u5e8f"},"content":{"rendered":"\n<p>\u548c1024\u51e0\u4e4e\u4e00\u6837\uff0c\u6211\u751a\u81f3\u53ea\u662f\u6539\u4e86\u51e0\u4e2a\u5224\u65ad\u5b57\u7b26\u5c31AC\u4e86\u3002<\/p>\n\n\n\n<p><del>\u4ece\u4fa7\u9762\u8bc1\u660e\u6211\u53ef\u80fd\u5199\u4e86\u4e00\u4e2a\u901a\u7528\u578b\u5224\u65ad\u7a0b\u5e8f<\/del><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> include&lt;iostream><br> include&lt;vector><br> include&lt;string><br> include&lt;algorithm><br> using namespace std;<br> struct CC {<br>     string str;<br>     int firstposition = 0;<br>     int amount = 0;<br>     void countA();<br>     void positionA();<br>     bool operator&lt;(const CC&amp; A) const     <br>    {         <br>         if (str.size() &lt; A.str.size()) \/\/\u68c0\u6d4b\u5b57\u7b26\u4e32\u957f\u5ea6<br>             return true;<br>         else if (str.size() > A.str.size())<br>             return false;<br> <code>    if (amount &lt; A.amount)  \/\/\u68c0\u6d4b1\u7684\u6570\u91cf<\/code><br><code>         return true;<\/code><br><code>     else if (amount > A.amount)<\/code><br><code>         return false;<\/code><br><code>     if (firstposition &lt; A.firstposition) \/\/\u68c0\u6d4bASCII\u7801\u503c\uff1f<\/code><br><code>         return true;<\/code><br><code>     else if (firstposition > A.firstposition)<\/code><br><code>         return false;<\/code><br><code>     return false;<\/code><br><code>     }<\/code><br> };<br> void CC::countA()<br> {<br>     int amount = 0;<br>     for (auto t : this->str)<br>         if (t == '1')<br>             amount++;<br>     this->amount = amount;<br> }<br> void CC::positionA()<br> {<br>     int i = 0;<br>     for (; i != (this->str).size(); i++)<br>         if (str[i] == '1')<br>             this->firstposition = i;<br> }<br> void print_each(const CC &amp; c)<br> {<br>     cout &lt;&lt; c.str &lt;&lt; endl; } int main() {     vector list;<br>     CC temp;<br>     while (cin >> temp.str)<br>     {<br>         temp.countA();<br>         temp.positionA();<br>         list.push_back(temp);<br>     }<br>     sort(list.begin(), list.end());<br>     for_each(list.begin(), list.end(), print_each);<br>     return 0;<br> }<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u548c1024\u51e0\u4e4e\u4e00\u6837\uff0c\u6211\u751a\u81f3\u53ea\u662f\u6539\u4e86\u51e0\u4e2a\u5224\u65ad\u5b57\u7b26\u5c31AC\u4e86\u3002 \u4ece\u4fa7\u9762\u8bc1\u660e\u6211\u53ef\u80fd\u5199\u4e86\u4e00\u4e2a\u901a\u7528\u578b\u5224\u65ad\u7a0b\u5e8f includ [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts\/705"}],"collection":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=705"}],"version-history":[{"count":0,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/posts\/705\/revisions"}],"wp:attachment":[{"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=705"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fankasy.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}