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/contest/1114/problem/B | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| int main(int, char**) { | |
| int n, m, k; | |
| cin >> n >> m >> k; | |
| vector< pair<int,int> > data(n); | |
| for (int i = 0; i < n; ++i) { |
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
| // recursive | |
| int gcd(int a , int b) | |
| { | |
| if (b == 0) return a; | |
| a %= b; | |
| return gcd(b, a); | |
| } | |
| // iterative | |
| int gcd(int a , int b) |
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
| // find max substring which has no repeating characters | |
| // https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ | |
| class Solution { | |
| public: | |
| int lengthOfLongestSubstring(string s) { | |
| if (s.length() == 0) return 0; | |
| int i = 0; | |
| int j = 0; | |
| vector<int> i2l(256, -1); |
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; | |
| // Explicit tree: using array | |
| const int N = 7; | |
| int tr[4*N + 1]; | |
| int maxV[4*N + 1]; | |
| void update(int cur, int L, int R, int l, int r) // increments by one corresponding vertices |
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 of https://arc097.contest.atcoder.jp/tasks/arc097_a | |
| // using string hashing | |
| // Good as a source of code for general hashing with reversed element | |
| // But overcomplicated for this problem -- it is possible to just generate all the | |
| // sustrings, sort/unique them and return k-th | |
| // | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long int lint; |
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
| # remap prefix to Control + q | |
| set -g prefix C-q | |
| unbind C-b | |
| bind C-q send-prefix | |
| # force a reload of the config file | |
| unbind r | |
| bind r source-file ~/.tmux.conf | |
| # quick pane cycling |
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/100094/attachments/download/1239/20122013-tryenirovka-spbgu-b-6-zaprosy-na-otryezkye-dyeryevo-otryezkov-2-ru.pdf | |
| // problem A using Implicit (dynamic) segment tree | |
| // For unknown reason it fails test 8 with TLE | |
| // Nevertheless might be useful as an example of dynamic implementation | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long int lint; | |
| const lint BIG = 1e9 + 1; | |
| struct Node { |
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/100094/attachments/download/1239/20122013-tryenirovka-spbgu-b-6-zaprosy-na-otryezkye-dyeryevo-otryezkov-2-ru.pdf | |
| // problem A using explicit segment tree | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long int lint; | |
| const int N = 1e6; | |
| int t[4*N+1]; |
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://informatics.mccme.ru/moodle/mod/statements/view.php?chapterid=3327#1 | |
| // Given an array A[1,..,n] it is required to implement two operations | |
| // 1) get(index) return A[index] | |
| // 2) add(l, r, val) A[l,..,r] += val | |
| // I used dynamic (also called implicit) segment tree | |
| // this type of implementation reduces space from O(N) to O(mlogN) | |
| #include <bits/stdc++.h> | |
| using namespace std; | |
| typedef long long int lint; |
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; | |
| class Resistance { | |
| public: | |
| bool pass(int a, vector<string>& missions) { | |
| for (auto& m : missions) { | |
| if (m[0] == 'F') { | |
| int mi = stoi(m.substr(1), nullptr, 2); | |
| if ((mi & a) == 0) |