Posts

Showing posts from December, 2016

Codeforces Whose sentence is it?

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; const int mod = 1000007; const int high = 100; class out { public:     void noregonize()     {         cout << "OMG>.< I don't know!\n";     }     void lala()     {         cout << "Freda's\n";     }     void miao()   ...

Codeforces New Year Table

#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back #define pi acos(-1.0) typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; const double eps = 1e-9; class newYear { public:     void solution(double n , double R , double r)     {         if(n == 1.0)         {             if(R >= r) pf("YES\n");             else pf("NO\n");             //continue;         }         else      ...

Codeforces Nineteen

Link: http://codeforces.com/problemset/problem/393/A /* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 100; mpci mp; char ch[10]={'e' , 'i' , 'n' , 't'}; class nineteen {     int len , i , ans=100003; public:     void solution(string s)     {         mp.clear();         ans = 1000005;      ...

Codeforces Appleman and Card Game

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 100; LL ar[256]; bool cmp(LL a, LL b) {      return a > b; } int main() {     fast;     LL n , k , i , ans=0;     string s;     while(cin >> n >> k)     {         ans=0;         memset(ar , 0, sizeof ar...

Codeforces Sort the Array

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; const int mod = 1000007; const int high = 100003; const int inf = 1000005; int ar[high] , br[high] , up[high]; int main() {     fast;     int n , i , j , x , y;     while(cin >> n)     {         for(i=0; i<n; i++)         {             cin ...

Codeforces Little Girl and Game

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(0) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 100; int main() {     fast;     string s ;     int i , len , cnt=0;     mpci mp;     while(cin >> s)     {         mp.clear();         len = s.length();         cnt=0;    ...

Codeforces Santa Claus and a Place in a Class

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     int n , m , i=1 , j;     LL k , tmp;     while(cin >> n >> m)     {         i = 0;         cin >> k;         tmp = 0;         while(tmp < k)   ...

Codeforces Vanya and Lanterns

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 1003; int ar[high]; int main() {     fast;     int n , l , i , mxdist=0;     double ans;     while(~sf("%d %d", &n , &l))     {         for(i=0; i<n; i++)         {             sf("%d", &ar[i]);   ...

Codeforces Taxi

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100003; int ar[high]; int main() {     fast;     int n , x , i , j , cnt=0;     while(cin >> n)     {         for(i=0; i<n; i++)         {             cin >> ar[i];         }   ...

Codeforces Comparing Strings

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int , int>mpci; const int mod = 1000007; const int high = 100; int main() {     fast;     int i;     mpci fr , se;     string first, second;     while(cin >> first >> second)     {         if(first.length() == second.length())         {      ...

Codeforces Mammoth's Genome Decoding

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<char, int>mpci; const int mod = 1000007; const int high = 300; //struct my //{ //    char ch; //    int wieght; //}ar[high]; int main() {     fast;     int n , len , i , j;     char ch[]={'A' , 'C' , 'G' , 'T'};     string s , ans;     mpci mp;     while(cin >> n)     {   ...

Codeforces Hongcow Learns the Cyclic Shift

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A little Magician in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     string s , tmp , parmanent;     int len , i , j , cnt=0;     while(cin >> s)     {         cnt=1;         parmanent = s;         len = s.length();         i = len-1; ...

Codeforces Chloe and the sequence

//I am Just Not Good at it #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     int n;     LL k;     while(cin >> n >> k)     {         int cnt=0;         while(k%2!=1)         {             cnt++;             k/=2;         }         cout << cnt+1 << "\n";   ...

Codeforces Vladik and fractions

/* Lionel Messi is such a player that you may catch him, you may touch him, you may feel him and definitely you may Love him. Lionel Messi is Messi. A piece of Greatness in this World. */ #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; const int mod = 1000007; const int high = 100; int main() {     fast;     LL n;     while(cin >> n)     {         if(n == 1)         {             cout << "-1\n";             continue;       ...

Codeforces Arpa’s obvious problem and Mehrdad’s terrible solution

//I am struggling //Just Not Good at it #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; const int mod = 1000007; const int high = 100003; int ar[high]; int main() {     fast;     int n , x , i , j ;     LL p , res=0;     mpii mp;     while(cin >> n >> x)     {         mp.clear();         for(i=1; i<=n; i++)         {             cin >> ar[i];           ...

Code chef Train Partner

//I am struggling //Just Not Good at it #include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false) #define bfast cin.tie(0) #define outs(x) cout << x << " " #define outn(x) cout << x << "\n" #define sf scanf #define pf printf #define nl puts("") #define psb push_back typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<int, string>mpsi; const int mod = 1000007; const int high = 600; mpii mp; mpsi ms; void partner() {     int i , cnt=0;     for(i=8; i<=high; i+=8)     {         mp[i] = i-1;         ms[i] = "SU";         mp[i-1] = i;         ms[i-1] = "SL";     }     for(i=1; i<=high; i++)     {         if(!...