June 28 CF Summary

Source: Internet
Author: User
Tags acos

June 28 CF Summary

Today CF advance to 10 o ' Day, still worse than midnight. The speed of the pit ah ...

A question: water problem.

In a 01 sequence, each time you delete 01 and 10, the length of the last remaining sequence is calculated.

The number of direct output 0 and 1 of the number of the difference can be, as long as the remaining 0 or 1 will be harmonious.

This problem 7 minutes to brush out the page, 11 minutes to understand test instructions, 13 minutes too drunk ... Network speed pit hand speed ah ...

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<vector>#include<stack>#include<queue>#include<Set>#include<map>#include<string>#include<math.h>#include<cctype>#definell Long Long#defineREP (I,A,B) for (int (i) = (a);(i) <= (b);(i) + +)#defineRepp (i,a,b,t) for (int (i) = (a);(i) <= (b);(i) + = (t))#defineRep (i,a,b) for (int (i) = (a);(i) >= (b);(i)--)#defineRepp (i,a,b,t) for (int (i) = (a);(i) >= (b);(i)-= (t))#definePII pair<int,int>#defineFST First#defineSND second#defineMP Make_pair#definePB push_back#defineRI (x) scanf ("%d",& (x))#defineRII (x, y) scanf ("%d%d",& (×),& (y))#defineRIII (x, Y, z) scanf ("%d%d%d",& (×),& (y),& (z))#defineDRI (x) int (x); scanf ("%d",& (x))#defineDrii (x, y), scanf ("%d%d",& (x),& (y))#defineDRIII (x, y), (z), scanf ("%d%d",& (x),& (y),& (z))#defineRS (x) scanf ("%s", X)#defineRSS (x, y) scanf ("%s%s", X, y)#defineDRS (x) char x[maxn];scanf ("%s", X)#defineDrss (x, y) char x[maxn],y[maxn];scanf ("%s%s", X, y)#defineMS0 (a) memset ((a), 0,sizeof ((a)))#defineMS1 (a) memset ((a), -1,sizeof ((a)))#defineMS (b) memset ((a), (b), sizeof ((a)))#defineAll (v) v.begin (), V.end ()#defineSZ (v) (int) (v). Size ()using namespacestd;Const intmaxn=1000100;Const intInf= (1<< in);Const Doubleeps=0.0000000001;Const DoublePi=acos (-1.0);strings;intN;intMain () { while(cin>>N) {cin>>s; intOne=0, zero=0; REP (i,0, SZ (s)-1){            if(s[i]=='0') zero++; Elseone++; } cout<<abs (One-zero) <<Endl; }    return 0;}
View Code

Question B: water problem.

For a set of gears, ask if you can go to the sequence of 0123,,, N.

Because it is a gear, the first turn +1, the second-1, the third +1, the fourth-1, ..., and so on.

So the first to go directly to 0, that is, turn-a[0] times, after the first even number of a[0] times, the odd number of a[0] times, the final state, the final sweep of judgement can be.

Gear Ah, no words ah ... Actually to find the law .... Direct simulation ah .... I'm so stupid.

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<vector>#include<stack>#include<queue>#include<Set>#include<map>#include<string>#include<math.h>#include<cctype>#definell Long Long#defineREP (I,A,B) for (int (i) = (a);(i) <= (b);(i) + +)#defineRepp (i,a,b,t) for (int (i) = (a);(i) <= (b);(i) + = (t))#defineRep (i,a,b) for (int (i) = (a);(i) >= (b);(i)--)#defineRepp (i,a,b,t) for (int (i) = (a);(i) >= (b);(i)-= (t))#definePII pair<int,int>#defineFST First#defineSND second#defineMP Make_pair#definePB push_back#defineRI (x) scanf ("%d",& (x))#defineRII (x, y) scanf ("%d%d",& (×),& (y))#defineRIII (x, Y, z) scanf ("%d%d%d",& (×),& (y),& (z))#defineDRI (x) int (x); scanf ("%d",& (x))#defineDrii (x, y), scanf ("%d%d",& (x),& (y))#defineDRIII (x, y), (z), scanf ("%d%d",& (x),& (y),& (z))#defineRS (x) scanf ("%s", X)#defineRSS (x, y) scanf ("%s%s", X, y)#defineDRS (x) char x[maxn];scanf ("%s", X)#defineDrss (x, y) char x[maxn],y[maxn];scanf ("%s%s", X, y)#defineMS0 (a) memset ((a), 0,sizeof ((a)))#defineMS1 (a) memset ((a), -1,sizeof ((a)))#defineMS (b) memset ((a), (b), sizeof ((a)))#defineAll (v) v.begin (), V.end ()#defineSZ (v) (int) (v). Size ()using namespacestd;Const intmaxn=1000100;Const intInf= (1<< in);Const Doubleeps=0.0000000001;Const DoublePi=acos (-1.0);intA[MAXN];intN;intMain () { while(cin>>N) {REP (i,0, N-1) RI (A[i]); BOOLflag=1; intt=a[0]; REP (i,0, N-1){            if(i&1) a[i]= (a[i]+t)%N; Elsea[i]= (a[i]+n-t)%N; } REP (I,0, N-1){            if(a[i]!=i) {Flag=0;  Break; }} puts (flag?"YES":"NO"); }    return 0;}
View Code

Question c: water problem.

That is, the Russian set of baby, big can set small, the premise is that there is no other set of other sets of other things, so want to set a chain can only from small to large sets, not from large to small sets.

Then we give several chains that have already been set up, and then we seek to reorganize the number of 1->2->...->n chains.

Because only from small to large sets, so direct simulation can, after the building (chain) from small to large judgment, the result is to add the number of operations + need to delete the operand.

Test instructions pit ..... After the game know test instructions seconds a ah ...

#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<vector>#include<stack>#include<queue>#include<Set>#include<map>#include<string>#include<math.h>#include<cctype>#definell Long Long#defineREP (I,A,B) for (int (i) = (a);(i) <= (b);(i) + +)#defineRepp (i,a,b,t) for (int (i) = (a);(i) <= (b);(i) + = (t))#defineRep (i,a,b) for (int (i) = (a);(i) >= (b);(i)--)#defineRepp (i,a,b,t) for (int (i) = (a);(i) >= (b);(i)-= (t))#definePII pair<int,int>#defineFST First#defineSND second#defineMP Make_pair#definePB push_back#defineRI (x) scanf ("%d",& (x))#defineRII (x, y) scanf ("%d%d",& (×),& (y))#defineRIII (x, Y, z) scanf ("%d%d%d",& (×),& (y),& (z))#defineDRI (x) int (x); scanf ("%d",& (x))#defineDrii (x, y), scanf ("%d%d",& (x),& (y))#defineDRIII (x, y), (z), scanf ("%d%d",& (x),& (y),& (z))#defineRS (x) scanf ("%s", X)#defineRSS (x, y) scanf ("%s%s", X, y)#defineDRS (x) char x[maxn];scanf ("%s", X)#defineDrss (x, y) char x[maxn],y[maxn];scanf ("%s%s", X, y)#defineMS0 (a) memset ((a), 0,sizeof ((a)))#defineMS1 (a) memset ((a), -1,sizeof ((a)))#defineMS (b) memset ((a), (b), sizeof ((a)))#defineAll (v) v.begin (), V.end ()#defineSZ (v) (int) (v). Size ()using namespacestd;Const intmaxn=1000100;Const intInf= (1<< in);Const Doubleeps=0.0000000001;Const DoublePi=acos (-1.0);intn,k,m;intA[maxn];map&LT;PII,int>G;intMain () { while(cin>>n>>k)        {g.clear (); intA=0, b=0, cnt=0;  while(k--) {RI (M); CNT+=m-1; REP (i,1, M)            RI (A[i]); REP (i,1, M-1) g[{a[i],a[i+1]}]=1; } REP (I,1, N-1){            if(g[{i,i+1}]) a++; Else  Break; } cout<< (n1-a) + (CNT-A) <<Endl; }    return 0;}
View Code

If the internet is good, the brain is not stupid, test instructions to understand, casually seconds a ah .... Casually rank before 200 ah, Chong Purple very casually ah ...

It seems that the words must be back ah, English reading also have to practice ah ...

Although the rating fell again this time. But the feeling is not far away from the purple ... Next time to register a new account, anyway xd560 prefix is very very bad, then how can brain remnants in front plus this stupid school to prefix ... Next to change the number of purple!!!

June 28 CF Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.