Codeforces Round #328 (DIV2)

Source: Internet
Author: User

Codeforces 592A

Test Instructions: in the 8*8 chessboard, there are Othello, F1 players (W chess up and down to the target point: line 1th) to go first, F2 players (b chess down-and finally to the target point: line 8th) second. The number of pieces is not necessarily equal, and one of the pieces in the F1,F2 first reaches the target point counterpart victory.

Ideas: W,b chess pieces can only be up and down, so you need to know: the closest to the first line of the W Chess distance S1 (and this w no b), the nearest eighth line of B chess distance S2 (below the B no W)

The winner is S1<=S2? F1:f2

Note: F1 wins when S1==s2.

Code:

1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 6 Charmp[Ten][Ten];7 8 intMain ()9 {Ten      for(intI=0;i<8; i++) Onescanf"%s", Mp[i]); A     intminb=Ten, minw=Ten, FW,FB,FLAGB; -      for(intI=0;i<8; i++) -     { thefw=Ten; fb=Ten; flagb=0; -          for(intj=0;j<8; j + +) -         { -             if(mp[j][i]=='W') +             { -                 if(flagb==0) +fw=min (fw,j); A                 Else atHbsTen; -             } -             if(mp[j][i]=='B') -             { -  -flagb=1; inFb=min (8-j-1, FB); -             } to         } +minb=min (MINB,FB); -minw=min (MINW,FW); the     } *     if(minb>=minw) $printf"a\n");Panax Notoginseng     Else -printf"b\n"); the}
View Code

Codeforces 592B

Test Instructions: there are n points, point-to-point connection, if there is a barrier, not skip. How many pieces are separated into. When N=5,.

idea: find the law. The first point to the other points is divided into n-2 blocks. Draw each point one at a time, recording the number of blocks that were more than the previous state. The two points around the first point are found to be n-3 blocks. The remaining points are n-4 blocks

So there is f[n]= (n-2) +2* (n-3) + (n-3) * (n-4) Simplification: f[n]= (n-2) ^2

Note: do not explode int, with a long long or _int64 output format%i64d.

Code:

1#include <iostream>2#include <cstdio>3#include <cstring>4 using namespacestd;5 6 intMain ()7 {8     Long LongN;9scanf"%i64d",&n);Tenprintf"%i64d\n", (n2) * (n2)); One     return 0; A}
View Code

Codeforces Round #328 (DIV2)

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.