CODEFORCES#348DIV2/VK CUP 2016

Source: Internet
Author: User
Tags bitset cmath

The first time yesterday to open the size of the CF, found that the original small large after the submission of the same code will be skipped off, and then submit the code is not scored, yesterday a,b,c are water problems

A

Test instructions: Ask an item can be divided into the maximum number of parts, divided into two consecutive parts can not be the same

Analysis: Directly to this part, so divided by 3 times 2, in the 3 modulo

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <string>5#include <vector>6#include <algorithm>7#include <Set>8#include <map>9#include <bitset>Ten#include <cmath> One#include <queue> A#include <stack> - using namespacestd; - intN; the intMain () - { -      while(cin>>N) -     { +         inth=n/3; -         Long Longsum=h*2; +         if(n%3) Acout<<sum+1<<Endl; at         Else -cout<<sum<<Endl; -     } -     return 0; -}
View Code

B

Test instructions: Jump within a certain range to determine if the end will jump out of range

Analysis: Direct Simulation

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <string>5#include <vector>6#include <algorithm>7#include <Set>8#include <map>9#include <bitset>Ten#include <cmath> One#include <queue> A#include <stack> - using namespacestd; - Const intmaxn=100002; the Const intmaxm=10000000; -typedefstructP - { -     CharC; +     intnum; - }p; + p S[MAXN]; A intN; at intMain () - { -      while(cin>>N) -     { -          for(intI=1; i<=n;i++) -Cin>>s[i].c; in          for(intI=1; i<=n;i++) -Cin>>S[i].num; to         intCnt=0; +         intpos=1; -          while(cnt<=MAXM) { the             if(s[pos].c=='>'){ *pos+=S[pos].num; $                 if(pos>n) Break;Panax Notoginsengcnt++; -}Else if(s[pos].c=='<'){ thepos-=S[pos].num; +                 if(pos<1) Break; Acnt++; the             } +         } -         if(CNT&LT;MAXM) cout<<"finite"<<Endl; $         Elsecout<<"INFINITE"<<Endl; $     } -     return 0; -}
View Code

C

Test instructions: Given some operations, 1 means that the specified row loops to the left, 2 means that the specified column loops up, and 3 means that the specified element is assigned a value

Analysis: Direct Simulation

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <string>5#include <vector>6#include <algorithm>7#include <Set>8#include <map>9#include <bitset>Ten#include <cmath> One#include <queue> A#include <stack> - using namespacestd; - Const intmaxn=102; the Const intmaxm=10010; - intA[MAXN][MAXN]; - intX[MAXM],Y[MAXM],R[MAXM],C[MAXM],T[MAXM]; - intn,m,q; + intMain () - { +      while(cin>>n>>m>>q) A     { atMemset (A,0,sizeof(a)); -          for(intI=0; i<q;i++) -         { -scanf"%d",&t[i]); -             if(t[i]==1) -             { inscanf"%d",&y[i]); -}Else if(t[i]==2){ toscanf"%d",&y[i]); +}Else{ -scanf"%d%d%d",&r[i],&c[i],&x[i]); the             } *         } $          for(inti=q-1; i>=0; i--)Panax Notoginseng         { -             intK; the             if(t[i]==3){ +a[r[i]][c[i]]=X[i]; A}Else if(t[i]==2){ thek=A[n][y[i]]; +                  for(intJ=n;j>1; j--) -a[j][y[i]]=a[j-1][y[i]]; $a[1][y[i]]=K; $}Else{ -k=A[y[i]][m]; -                  for(intJ=m;j>1; j--) thea[y[i]][j]=a[y[i]][j-1]; -a[y[i]][1]=K;Wuyi  the             } -         } Wu          for(intI=1; i<=n;i++) -         { About              for(intj=1; j<m;j++) $printf"%d", A[i][j]); -printf"%d\n", A[i][m]); -         } -     } A  +     return 0; the}
View Code

CODEFORCES#348DIV2/VK CUP 2016

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.