Codeforces Round #384 (Div. 2)//review-like pressure ... Explode boom at penalty

Source: Internet
Author: User

Don't want to owe the question .... More dozen dozen CF just know oneself IQ is insufficient ah ...

A. Vladik and flights

Give you a 01 string the same between casually fly no cost different fly need cost for ABS I-j

Really test instructions kill Ah,,, actually we only consider the cost of 01 conversion must be 1 if the destination and the starting point of the same cost is 0

The difference is definitely 1 because 0 is bound to have 1

#include <cstdio>#include<iostream>#include<algorithm>#include<vector>#include<Set>#include<string.h>#include<cctype>#include<climits>using namespaceStd;typedefLong Longll;template<classT>inlineBOOLR (T &ret) {    CharC; intSGN; if(c = GetChar (), c = =EOF) {        return 0;//EOF    }     while(c! ='-'&& (C <'0'|| C >'9') ) {C=GetChar (); } SGN= (c = ='-') ? -1:1; RET= (c = ='-') ?0: (C-'0');  while(c = GetChar (), C >='0'&& C <='9') {ret= RET *Ten+ (C-'0'); } ret*=SGN; return 1;}Const intN = 1e5+Ten;CharCh[n];intMain () {intN;    R (N); intx, y;    R (x), R (y); scanf ("%s", ch+1); if(ch[x]==Ch[y]) {printf ("0\n"); }    Else{printf ("1\n"); }    return 0;}
ZZ

B. Chloe and the sequence

Give an n and then follow the nth string of 1 121 1213121

Then must be two points n times to be .... The game is written in Python (l+r) without parentheses T1

N,k = Map (int, input (). Split ()) def calc (k): L=0R=2**N M= L+r//2Ans =0     while(k!=M):if(k>M): L=MElse: R=m M= (l+r)//2ans+=1Print (n-ans) Calc (k)
Py

C. Vladik and Fractions

Asked 2/n can be 1/a+1/b+1/c (a,b,c not the same) too careless, did not see the same WA1 no special sentenced 1 was hack 1

Hand push a = n b = n+1 c = N (n+1)

N=1 can't make it out.

#include <cstdio>#include<iostream>#include<algorithm>#include<vector>#include<Set>#include<string.h>#include<cctype>#include<climits>using namespaceStd;typedefLong Longll;template<classT>inlineBOOLR (T &ret) {    CharC; intSGN; if(c = GetChar (), c = =EOF) {        return 0;//EOF    }     while(c! ='-'&& (C <'0'|| C >'9') ) {C=GetChar (); } SGN= (c = ='-') ? -1:1; RET= (c = ='-') ?0: (C-'0');  while(c = GetChar (), C >='0'&& C <='9') {ret= RET *Ten+ (C-'0'); } ret*=SGN; return 1;}intMain () {intN;    R (N); if(n==1) printf ("-1"); Elseprintf"%d%d%d\n", n,n+1, N (n+1)); return 0;}
AC

D.chloe and Pleasant Prizes

MK, please.

E. Vladik and Cards

Test instructions A string of 1-8 to select a substring (in the original string can be discontinuous) the string of each number of the same must be adjacent and the number of each is not more than 1

The game only thought of the DFS solution, and later proved to be wrong

Later look at someone else's code a face mask =. =... Then a god said two arrays to understand the role of ... So refer to the wording of Claris

And....

This also wrote for a long time and also less update status length can be 0 ...

#include <cstdio>#include<cstring>voidMin (int&a,intb) {if(a>b) a=b;}voidMax (int&a,intb) {if(a<b) a=b;}Const intMAXN =1010;intcnt[Ten];intg[maxn][maxn][Ten];//I J Kintdp[ the][Ten];//I selection scheme J represents the length of the set number of maximum n/8+1intVAL[MAXN];intN;intMain () {scanf ("%d",&N);  for(intI=1; i<=n;i++) scanf ("%d", &val[i]), val[i]--;  for(intI=1; i<=n;i++)    {         for(intj=1; j<=n+5; j + +)             for(intk=0; k<=8; k++) G[i][j][k] =MAXN; memset (CNT,0,sizeof(CNT));  for(intj=i;j<=n;j++) g[i][++CNT[VAL[J]]][VAL[J]] =J; }    intAns =0;  for(intI=0; i*8<=n;i++)//length    {         for(intj=0;j< the; j + +)             for(intk=0; k<=8; k++) Dp[j][k]=MAXN; dp[0][0] =1;//starting from 1         for(intj=0;j< the; j + +)//Select a scenario        {             for(intk=0; k<=8; k++)//             {                if(dp[j][k]>n)Continue;  for(intL=0;l<8; l++)                {                    if((1&LT;&LT;L) &j)Continue; Min (Dp[j| (1&LT;&LT;L)][k],g[dp[j][k]][i][l]+1); Min (Dp[j| (1&LT;&LT;L)][k+1],g[dp[j][k]][i+1][l]+1); }            }        }         for(intj=0; j<=8; j + +)if(dp[255][j]<n+2) {Max (ans,j+8*i); }} printf ("%d\n", ans); return 0;} 
pressure DP

Codeforces Round #384 (Div. 2)//review-like pressure ... Explode boom at penalty

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.