Codeforces Round #410 (Div. 2), problem: (E) Mike and code of a permutation Solution In C/C++

By | 2017-07-24T01:51:42+00:00 July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#pragma warning(disable:4996) #include <stdio.h> #include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <string.h> #include <stdlib.h> #include <assert.h> #include <cmath> #include <map> #include <set> #include <queue> #include <complex> #include <iterator> #include <random> #include <time.h> #include <tuple> #include <functional> #include <list> #include <limits.h> #define mp [...]

Codeforces Round #410 (Div. 2), problem: (D) Mike and distribution Solution In C/C++

By | 2017-07-24T01:48:57+00:00 July 24th, 2017|Categories: C/C++, Programming|Tags: , , , , , , |

#include<bits/stdc++.h> using namespace std; const int maxn=100000+10; int b[maxn],n,flag=1,dp[maxn]; struct node { int id,x; }a[maxn]; int cmp(node a,node b) { return a.x>b.x; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i].x); a[i].id=i; } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++) scanf("%d",&b[i]); int k=n/2+1; printf("%d\n%d\n",k,a[1].id); for(int i=2;i<=n;i+=2) if(b[a[i].id]>b[a[i+1].id]) printf("%d\n",a[i].id); [...]

Codeforces Round #410 (Div. 2), problem: (C) Mike and gcd problem Solution In C/C++

By | 2017-07-24T01:47:22+00:00 July 24th, 2017|Categories: C/C++, Programming|Tags: , , |

#include <bits/stdc++.h> using namespace std; int main(){ int n, num = 0, x, sum = 0; scanf("%d", &n); int g=0; for(int i = 0; i < n; ++i){ scanf("%d", &x); g=__gcd(g,x); if(x&1){ num ++; }else{ sum = sum + num/2 + (num%2)*2; num = [...]

Codeforces Round #410 (Div. 2), problem: (B) Mike and strings Solution In C/C++

By | 2017-07-24T01:45:48+00:00 July 24th, 2017|Categories: Uncategorized|Tags: , , , , , , , |

#include <bits/stdc++.h> using namespace std; string s[51]; int main() { int n, t, ans; ans = INT_MAX; cin>>n; string temp; for(int i=0; i<n; i++) cin>>s[i]; for(int i=0; i<n; i++) { t = 0; for(int j=0; j<n; j++) { temp=s[j]+s[j]; if(temp.find(s[i])==string::npos) { cout<<-1<<endl; return 0; [...]

Codeforces Round #410 (Div. 2), problem: (A) Mike and palindrome Solution In C/C++

By | 2017-07-24T01:37:53+00:00 July 24th, 2017|Categories: C/C++, Programming|Tags: , , |

#include<iostream> using namespace std; main() { string s;cin>>s; int n=s.size(),cnt=0; for(int i=0;i<n/2;i++) { if(s[i]!=s[n-i-1])cnt++; } cout<<(cnt==1||cnt==0&&n%2==1?"YES":"NO")<<endl; }