This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Kinda long solution | |
// Complexity - nlogn | |
#include <bits/stdc++.h> | |
using namespace std; | |
int getLargestAConst(const vector<int>& a) { | |
int maxL = 0; | |
int l = 0, r = 0; | |
map<int, int> subseq; | |
while (r != a.size()) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The problem is taken from https://www.e-olymp.com/en/problems/2157 | |
*/ | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
lint mod = 1e9; | |
vector<list<int>> adj; | |
vector<bool> visited; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
timing: | |
first submision 36m | |
bug fixing 10m | |
*/ | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
typedef long double ldouble; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Solution for "Intel Code Challenge Elimination Round (Div. 1 + Div. 2, combined)" | |
Problem C, Destruction of Array | |
http://codeforces.com/contest/722/problem/C | |
I used modified DisjointSet (additionally stores sum of elements in connected component) | |
Bitmask to check neighbors | |
*/ | |
#include <bits/stdc++.h> | |
using namespace std; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://codeforces.com/gym/100126/attachments/download/1321/20122013-tryenirovka-spbgu-b-15-heshi-ru.pdf | |
// Problem A | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
typedef long double ldouble; | |
const lint p = 307; | |
const lint M = lint(1e9) + 7; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://codeforces.com/gym/100371/attachments/download/2258/2014-zimnyaya-shkola-po-programmirovaniu-harkov-dyen-1-ye-kapun-vysshaya-liga-ru.pdf | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
typedef long double ldouble; | |
typedef pair<lint, int> E; | |
int n; | |
vector<vector<E>> adj; // weight, vtx | |
vector< vector<int> > parents; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Solution for http://codeforces.com/gym/220829/problem/B | |
// | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
typedef long double ldouble; | |
typedef pair<int, int> E; | |
int n; | |
vector<vector<int>> adj, revadj; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Solution for educational round 36, F | |
http://codeforces.com/problemset/problem/915/F | |
I used modified DisjointSet (additionally stores size of set) | |
*/ | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
class disjoint_sets |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// solution for CF VK Cup 2017, round 1, problem C | |
// http://codeforces.com/contest/769/problem/C | |
// The idea: | |
// Front step) we go greedy until it is possible to go back from the current cell | |
// This check is done by the help of shortest distance matrix d | |
// Back step) Find the lexigocraphically optimal backward path following distance matrix d | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
typedef long double ldouble; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long int lint; | |
typedef long double ldouble; | |
const int N = 1<<17 + 1; | |
int a[N]; | |
int t[4*N]; | |
void build(int cur, int L, int R, int level) { | |
if (L == R) { // level == 0 |