Codeforces Round #385 (Div. 2), problem: (E) Hongcow Buys a Deck of Cards Solution in C/C++

By |2017-04-07T22:11:46+00:00December 18th, 2016|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<bits/stdc++.h> using namespace std; const int maxn=16,INF=0x3f3f3f3f; char type[maxn]; int R[maxn],B[maxn]; char readchar() { for(;;) { char ch=getchar(); if(!isspace(ch)) { return ch; } } } int n; typedef pair<int,int> pii; typedef set<pii> Spii; Spii dp[1<<maxn]; void Insert(Spii& s,const pii& p) { Spii::iterator it=s.lower_bound(p); if(it==s.begin()||(--it)->second>p.second) [...]

Codeforces Round #385 (Div. 2), problem: (D) Hongcow’s Game Solution in C/C++

By |2017-04-07T22:11:47+00:00December 18th, 2016|Categories: C/C++, Programming|Tags: , , , , , , |

#include <limits.h> #include <stdio.h> #define N 1000 void query(int *ww, int *aa, int k, int n) { int i; printf("%d\n", k); for (i = 0; i < k; i++) printf("%d ", ww[i]); printf("\n"); fflush(stdout); for (i = 1; i <= n; i++) scanf("%d", &aa[i]); [...]

Codeforces Round #385 (Div. 2), problem: (C) Hongcow Builds A Nation Solution in C/C++

By |2017-04-07T22:11:47+00:00December 18th, 2016|Categories: C/C++, Programming|Tags: , , |

#include <stdio.h> #include <string.h> int c[1005], p[1005], sz[1005], gov[1005]; int find_parent(int n) { if (p[n] == n) return n; return p[n] = find_parent(p[n]); } int get_full_size(int n) { return n * (n-1) / 2; } int main(int argc, char** argv) { int i, n, [...]

Codeforces Round #385 (Div. 2), problem: (B) Hongcow Solves A Puzzle Solution in C/C++

By |2017-04-08T18:37:51+00:00December 18th, 2016|Categories: C/C++, Programming|Tags: , , |

#include <limits.h> #include <stdio.h> int main() { int i, j, n, m, cnt, imin, jmin, imax, jmax; static char cc[500][501]; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%s", cc[i]); imin = jmin = INT_MAX; imax = jmax = 0; cnt [...]

Codeforces Round #385 (Div. 2), problem: (A) Hongcow Learns the Cyclic Shift Solution in C/C++

By |2017-04-07T22:11:47+00:00December 18th, 2016|Categories: C/C++, Programming|Tags: , , |

#include<stdio.h> #include<string.h> void cycle(char s[],int len) { char temp=s[len-1]; int i; for(i=len-1;i>0;i--) { s[i]=s[i-1]; } s[0]=temp; } int main(){ char s[51],orig[51]; int len,count=0; scanf("%s",s); len=strlen(s); strcpy(orig,s); do { cycle(s,len); count++; } while(strcmp(orig,s)); printf("%d\n",count); return 0; }