Posts

Showing posts from February, 2017

Hackerearth Happy Vertices

/* 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. */ // Accepted #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 loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) #define psb push_back typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; cons

Dev Skill Divisor - Multiple

/* 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 #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int hig

Codeforces A Serial Killer

/* 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. */ // Accepted #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 loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef vector<string>vs; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL&

Codeforces Borze

/* 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. */ // Accepted #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 loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 100; struct prin

Codeforces Beautiful Matrix

/* 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. */ // Accepted #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 loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 100; struct prin

Codeforces Ultra-Fast Mathematician

/* 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 #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 100; struct printf {     voi

Codeforces Soft Drinking

/* 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 #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; int main() {     fast;     LL n , k , l , c , d , p , Nl , Np , drink=0 , limes=0 , salt=0;     while(cin >> n >> k >> l >> c >> d >> p >> Nl >> Np)     {         drink = (k * l) / Nl;         limes = c * d;        

Codeforces Amusing Joke

/* 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 #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 100; struct printf {     voi

Dev Skill Journey By Circle

Problem Link: Journey By Circle /* 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 #define loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() #define pi acos(-1.0) typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int h

Dev Skill Even divisor

/* 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. */ // Odd numbers has no any Even divisor #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 loop0(n) for(int i=0; i<n; i++) #define loop1(n) for(int i=1; i<=n; i++) #define mpair(x , y) make_pair(x , y) #define all(x) x.begin(), x.end() typedef unsigned long long ull; typedef long long LL; typedef vector<int>vii; typedef vector<LL>vll; typedef map<int, int>mpii; typedef map<string, int>mpsi; typedef map<char, int>mpci; typedef map<LL, LL>mpll; const int mod = 1000007; const int high = 10000003; s

LightOj 1089 - Points in Segments (II)

/* 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. */ /* why array compression is needed? Ans: due to the segment's element size 10^8 and the size of segment is 5*10^4, but you have to take the perfect size to array compress is 2*10^5, because you are saving every distinct elements with the difference of 2. our condition is A <= Px <= B, due to this condition we have to increase our first and decrease our second element of the segment, at last we have to do cumulative sum to identify how many segment is needed for a points. */ #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 l

Ligthoj 1188 - Fast Queries

#include<cstdio> #include<cstring> #include<iostream> #include<cmath> #include<algorithm> #include<map> using namespace std; #define sf scanf #define pf printf typedef map<int, int>mpii; const int high = 100003; struct Query {     int L , R , i; }q[50007]; int ar[high] , ans[50007] , block=0 , answer=0 , mp[high]; bool cmp(Query x , Query y) {     if(x.L/block != y.L/block) return x.L/block < y.L/block;     return x.R < y.R; } void add(int pos) {     mp[ar[pos]]++;     if(mp[ar[pos]] == 1) answer++; } void rmoving(int pos) {     mp[ar[pos]]--;     if(mp[ar[pos]] == 0) answer--; } void Results(int n , int m) {     block = (int)sqrt(n);     sort(q , q+m , cmp);     int i , currR = 0 , currL = 0 , L , R;     for(i=0; i<m; i++)     {         L = q[i].L;         R = q[i].R;         while(currL < L)         {             rmoving(currL);             currL++;         }         while(currL > L)         {             add(currL-1);