code
stringlengths
1
2.06M
language
stringclasses
1 value
#ifndef _DATA_SET_LOADER_H_ #define _DATA_SET_LOADER_H_ #include "DataStructure.h" #include <istream> #include <fstream> // reads an external dataset file, creates and builds up a new data structure DataStructure* loadDataSet(const char* filepath); #endif
C++
#ifndef _FORMAL_CONTEXT_H_ #define _FORMAL_CONTEXT_H_ #include "OAPair.h" #include <vector> // local formal context class FormalContext { public: FormalContext() : processedNo(0) {} FormalContext(const FormalContext &); ~FormalContext(); unsigned int processedNo; std::vector<OAPair> data...
C++
#ifndef _DATA_STRUCTURE_H_ #define _DATA_STRUCTURE_H_ #include "Attribute.h" #include "AttributeSet.h" #include "Object.h" #include "ObjectSet.h" #include <vector> #include <map> #include <ostream> // main storage structure class DataStructure { public: DataStructure(); ~DataStructure(); /...
C++
#ifndef _ATTRIBUTE_SET_H_ #define _ATTRIBUTE_SET_H_ #include "Attribute.h" #include <set> // set of attributes class AttributeSet{ public: AttributeSet(){ this->processed = false; this->data.clear(); } AttributeSet(const AttributeSet &other){ this->processed = other.processed; for(std::set...
C++
#ifndef _OA_PAIR_H_ #define _OA_PAIR_H_ #include "AttributeSet.h" #include "ObjectSet.h" // ObjectSet and AttributeSet pair concise representation typedef std::pair<ObjectSet*, AttributeSet*> OAPair; // standard comparator bool OAPairCompare(const OAPair& e1, const OAPair& e2); #endif
C++
#ifndef _KOV_H_ #define _KOV_H_ // declaration of structures used in KOV algorithm implementation #include "..\common\Attribute.h" #include "..\common\AttributeSet.h" #include "..\common\Object.h" #include "..\common\ObjectSet.h" #include "..\common\OAPair.h" #include "..\common\FormalContext.h" #include "...
C++
/** * Implementation of Closure function * * author: Marcin Wachulski * */ #include "KOV.h" #include <set> #include <algorithm> #include <iterator> void ClosureForEmptySet(const AttributeSet &all_attrs, OAPair &oa_pair, FormalContext &local_fc) { if (local_fc.data.size() > 0) { OAPair &fc...
C++
#include "kov.h" int main(int argc, char *argv[]) { _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT ); try { DataStructure* data = loadDataSet(argv[1]); data->printSummary(std::cout); std::ofstream fc(argv[2]); clock_t...
C++
/** * Functions responsible for determining the local context for the KOV algorithm. * * author: Maciej Rubikowski */ #include "kov.h" #include <time.h> #include <Windows.h> typedef std::pair<ObjectSet, FormalContext*> ObjectContextPair; typedef std::vector<ObjectContextPair> LocalContextGrouping; Forma...
C++
/** * Implementation of Order function * * author: Marcin Wachulski * */ #include "KOV.h" #include <algorithm> void Order(FormalContext &local_fc, bool (*sort_f)(const OAPair &e1, const OAPair &e2)) { if (local_fc.data.size() < 2) return; std::sort(local_fc.data.begin(), local_fc.data....
C++
#include <iostream> #include <vector> using namespace std; template <typename T> void read(vector <T> &data) { int length; cin >> length; if (length == 4) throw 1; data.resize(length); for (int i = 0; i < length; ++i) { cin >> data[i]; } return; } template <typename iterat...
C++
#include <fstream> #include <vector> using namespace std; template <typename T> void read(vector <T> &data) { int length; ifstream in("input.txt"); in >> length; data.resize(length); for (int i = 0; i < length; ++i) { in >> data[i]; } return; } template <typename T> void max_to_end...
C++
#include <fstream> #include <vector> using namespace std; template <typename T> void read(vector <T> &data) { int length; ifstream in("input.txt"); in >> length; data.resize(length); for (int i = 0; i < length; ++i) { in >> data[i]; } return; } template <typename T> void max_to_end...
C++
#include <iostream> #include <vector> using namespace std; template <typename T> void read(vector <T> &data) { int length; cin >> length; data.resize(length); for (int i = 0; i < length; ++i) { cin >> data[i]; } return; } template <typename iterator, typename T> iterator partition(ite...
C++
#include <iostream> #include <vector> using namespace std; template <typename T> void read(vector <T> &data) { int length; cin >> length; data.resize(length); for (int i = 0; i < length; ++i) { cin >> data[i]; } return; } template <typename T> void merge(T first_begin, T first_end, ...
C++
#include <iostream> #include <vector> using namespace std; template <typename T> void read(vector <T> &data) { int length; cin >> length; data.resize(length); for (int i = 0; i < length; ++i) { cin >> data[i]; } return; } template <typename T> void merge(T first_begin, T first_end, T ...
C++
#include <bits/stdc++.h> using namespace std; bool dfs(int v, vector <vector <int> > &g, vector <int> &p, vector <bool> &u) { u[v] = 1; for (auto to: g[v]) { if (p[to] == -1) { p[to] = v; return 1; } if (u[p[to]]) { continue; } if (dfs(p[to], g, p, u)) { p[to] = v; return 1; ...
C++
#include <bits/stdc++.h> using namespace std; const int inf = (int)1e9 + 1; struct node { int value; char color; node *left, *right; node *parent; node() : value(inf + 1), color(0), left(NULL), right(NULL), parent(NULL) {} }; typedef node* tree; void right_turn(tree &t, tree &father, tree &root, tree &uncle) ...
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back #define rs resize #define mp make_pair #define pi 3.1415926535897932384626433832795 #define sz(a) (int)(a).size() #define Sort(a) sort((a).begin(), (a).end()) #define Reverse(a) reverse((a).begin(), (a).end()) #define sf scanf #define pf pri...
C++
#include <bits/stdc++.h> using namespace std; template <typename T> struct heap { int k; vector <T> a; heap(int k) : k(k) { a.reserve(10000000); } void sift_up(int v) { if (v == 0) { return; } int p = (v - 1) / k; if (a[p] > a[v]) { swap(a[p], a[v])...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::swap; using std::vector; struct edge { int v, u, cost; edge() {} edge(int v, int u, int cost) : v(v), u(u), cost(cost) {} }; void input(int &n, vector <edge> &graph) { int m, k; cin >> n >> m >> k; for (...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::set; using std::vector; using std::pair; using std::max; void read(int &n, vector <int> &t, vector <vector <int> > &g) { cin >> n; t.resize(n + 1); g.resize(n + 1); for (int i = 1; i <= n; ++i) { cin >> t[i]; ...
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector <pair <int, int> > a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; } sort(a.begin(), a.end(), [](pair <int, int> a, pair <int, int> b) { return a.second > b.second; }); long long s = 0; ...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::swap; using std::vector; struct edge { int v, u, cost; edge() {} edge(int v, int u, int cost) : v(v), u(u), cost(cost) {} }; void input(int &n, vector <edge> &graph) { int m; cin >> n >> m; graph.resize(...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::vector; void dfs(int v, vector <int> &x, vector <int> &y, int k, vector <bool> &used) { used[v] = 1; for (int i = 0; i < used.size(); ++i) { if (!used[i] && (x[i] - x[v]) * (x[i] - x[v]) + (y[i] - y[v]) * (y[i] - y[v]) <= k ...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::endl; using std::vector; enum COLORS{ BLACK = 2, WHITE = 0, GREY = 1 }; void dfs(int v, vector <vector <int> > &graph, vector <COLORS> &color, vector <int> &topsort, bool found_cycles) { color[v] = GREY; for (int to: graph[v]) { ...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::pair; using std::queue; using std::vector; const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; const int inf = (int)1e9; int main() { int m, n; cin >> m >> n; int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; --x1, --y1, --x2,...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::min; using std::vector; const int infinity = (int)1e9 + 1; int main() { int n, m; cin >> n >> m; vector <vector <int> > grid(n, vector <int>(m, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { ...
C++
#include <bits/stdc++.h> using std::cin; using std::cout; using std::vector; const int MODULO = 268435459; int main() { int n, m; cin >> n >> m; vector <vector <int> > grid(n, vector <int>(m, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> gri...
C++
int main() { return 0; }
C++
#include <bits/stdc++.h> // smart pointers are not very useful here due to high overhead struct node { node *prev; node *ch[2]; int key; void setCh(int x, node *n) { ch[x] = n; if (n != nil) n->prev = this; } bool red; static node *const nil; node() {} priva...
C++
#include <bits/stdc++.h> template <typename It, class Func> It my_partition(It begin, It end, Func f) { if (begin == end) return begin; It iter = begin; for (It it = begin; it != end; ++it) { if (f(*it)) { std::iter_swap(iter, it); ++iter; } } return ...
C++
#include <bits/stdc++.h> //* FOR C++ < 14 namespace std { template <> struct less<void> { template <class A, class B> auto operator()(const A &a, const B &b) -> decltype(a < b) { return a < b; } }; } //*/ template<class InputIt1, class InputIt2, class OutputIt, ...
C++
#include <bits/stdc++.h> template <typename It, class Compare = std::less<typename std::iterator_traits<It>::value_type> > It my_partition(It begin, It end, const typename std::iterator_traits<It>::value_type &x, Compare comp = Compare()) { typedef typename std::iterator_tra...
C++
#include <bits/stdc++.h> template <typename FwdIter, class Comp = std::less<typename std::iterator_traits<FwdIter> ::value_type> > void selectSort(FwdIter begin, FwdIter end, Comp cmp = Comp()) { while (end != begin) { auto it = std::max_element(begin, end, cmp); ...
C++
#include <bits/stdc++.h> template <typename FwdIter, class Comp = std::less<typename std::iterator_traits<FwdIter> ::value_type>> void swapMaximum(FwdIter begin, FwdIter end, Comp cmp = Comp()){ std::iter_swap(max_element(begin, end, cmp), std::prev(end))...
C++
#include <bits/stdc++.h> namespace std { // I hate ancient compilers template <> struct less<void> { template <class A, class B> auto operator()(const A &a, const B &b) -> decltype(a < b) { return a < b; } }; } template<class InputIt1, class InputIt2, class OutputIt, ...
C++
#include <bits/stdc++.h> class DSU { mutable std::vector<int> dsu_; std::vector<int> siz_; public: DSU(std::size_t size) : dsu_(size), siz_(size, 1) { std::iota(dsu_.begin(), dsu_.end(), 0); } int root(int x) const { int r = x; while (dsu_[r] != r) r = dsu_[r]; ...
C++
#include <bits/stdc++.h> class IncorrectGameStateException : public std::exception { public: const char *what() const noexcept override; }; class IncorrectGameMoveException : public std::exception { public: const char *what() const noexcept override; }; template <typename Result=int, class Iter> auto countOb...
C++
#include<iostream> #include<vector> #include<algorithm> using std::cin; using std::cout; using std::vector; using std::min; using std::pair; using std::make_pair; struct Point { int x, y; Point(int x, int y) : x(x), y(y) { } Point() : x(0), y(0) { } }; int distance(Point first, Point second) { ...
C++
#ifndef GAME_STATE_H_INCLUDED #define GAME_STATE_H_INCLUDED #include<iostream> #include<vector> #include<algorithm> #include<cstdlib> #include<time.h> using std::pair; using std::make_pair; using std::vector; class GameState { private: int alphabet_sz; int length; vector<int> sequence; int bulls; ...
C++
#include<iostream> #include<vector> #include<queue> #include<algorithm> #include<cstdlib> #include<limits.h> #include<time.h> #include<iterator> using std::cin; using std::cout; using std::vector; using std::min; using std::pair; using std::make_pair; using std::queue; const vector<int> dx {1, 0, 0, -1}; const vector...
C++
#include<iostream> #include<vector> using std::pair; using std::make_pair; using std::vector; using std::cin; using std::cout; const int white = 0; const int grey = 1; const int black = 2; struct Graph { vector<vector<int> > graph; vector<int> color; Graph(vector<vector<int> > &graph) : graph(graph), col...
C++
#include<iostream> #include<vector> #include<algorithm> using std::cin; using std::cout; using std::vector; using std::min; int main() { int n, m; cin >> n >> m; vector<vector<int> > path_cost(n); for (int i = 0; i < n; ++i) { path_cost[i].resize(m); for (int j = 0; j < m; ++j) { ...
C++
#include<iostream> #include<vector> #include<queue> #include<algorithm> #include<cstdlib> #include<limits.h> #include<iterator> #include<time.h> using std::cin; using std::cout; using std::vector; using std::pair; using std::make_pair; const int white = 0; const int grey = 1; const int black = 2; typedef vector<vect...
C++
#include<iostream> #include<vector> #include<algorithm> using std::cin; using std::cout; using std::vector; using std::min; const int MAGIC_CONST = 268435459; int main() { int n, m; cin >> n >> m; vector<vector<bool> > is_clear(n); vector<vector<int> > path_number(n); for (int i = 0; i < n; ++i) ...
C++
#include <iostream> #include <algorithm> struct Interval { double left, right, cost; Interval (double left, double right, double cost) :left(left), right(right), cost(cost) { } Interval () { } }; void readInput (std::vector<Interval> &input_data, int amount) { fo...
C++
#include <iostream> #include <vector> void ReadInput (std::vector <int> &elements, int array_size) { for (int iteration = 0; iteration < array_size; ++iteration) { int element; std::cin >> element; elements.push_back(element); } } template <typename iterator_type> void MaxI...
C++
#include <iostream> #include <vector> void ReadInput (std::vector <int> &elements, int array_size) { for (int iteration = 0; iteration < array_size; ++iteration) { int element; std::cin >> element; elements.push_back(element); } } template <typename iterator_type, typename d...
C++
#include <iostream> #include <vector> void ReadInput (std::vector <int> &elements, int array_size) { for (int iteration = 0; iteration < array_size; ++iteration) { int element; std::cin >> element; elements.push_back(element); } } void PrintAnswer (std::vector <int> &answer)...
C++
#include <iostream> #include <vector> void ReadInput (std::vector <int> &elements, int array_size) { for (int iteration = 0; iteration < array_size; ++iteration) { int element; std::cin >> element; elements.push_back(element); } } void PrintAnswer (std::vector <int> &answer)...
C++
#include <iostream> #include <vector> void ReadInput (std::vector <int> &elements, int array_size) { for (int iteration = 0; iteration < array_size; ++iteration) { int element; std::cin >> element; elements.push_back(element); } } template <typename iterator_type> void MaxI...
C++
#include <iostream> #include <vector> #include <cstdlib> void ReadInput (int *elements, int array_size) { for (int iteration = 0; iteration < array_size; ++iteration) { int element; std::cin >> element; *(elements + iteration) = element; } } template <typename iterator_type...
C++
#include <iostream> #include <vector> class Dfs { public: std::vector<std::vector<int> > *graph; std::vector <bool> used; Dfs (std::vector<std::vector<int> > *graph):graph(graph) { for (int i = 0; i < graph->size(); ++i) { used.push_back(false); } }; vir...
C++
int main() { }
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::cin; using std::cout; using std::vector; template<typename Iter, typename Comp> Iter Max_to_end(Iter begin, Iter end, Comp cmp) { if (begin == end) { return end; } Iter max_position = std::max_element(begin, end, cmp); --e...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <cassert> using std::cin; using std::cout; using std::vector; template<typename Iter, typename Comp> Iter Partition(Iter begin, Iter end, typename std::iterator_traits<Iter>::value_type elem, Comp cmp) { if (begin == end) { ret...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <cassert> using std::cin; using std::cout; using std::vector; template<typename Iter, typename Comp> Iter Merge(Iter begin1, Iter end1, Iter begin2, Iter end2, Iter out, Comp cmp) { while (begin1 != end1 && begin2 != end2) { if...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::cin; using std::cout; using std::vector; template<typename Iter, typename Comp> Iter Merge(Iter begin1, Iter end1, Iter begin2, Iter end2, Iter out, Comp cmp) { while (begin1 != end1 && begin2 != end2) { if (cmp(*begin1, *beg...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::cin; using std::cout; using std::vector; template<typename Iter, typename Comp> Iter Max_to_end(Iter begin, Iter end, Comp cmp) { if (begin == end) { return end; } Iter max_position = std::max_element(begin, end, cmp); --e...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <cassert> #include <cstdlib> #include <utility> using std::cin; using std::cout; using std::vector; template<typename Iter, typename Comp> Iter Partition(Iter begin, Iter end, typename std::iterator_traits<Iter>::value_type elem, ...
C++
#include <iostream> #include <vector> #include <utility> using std::cin; using std::cout; using std::endl; using std::vector; using std::pair; using std::make_pair; void Input(vector<vector<int> > *matrix) { size_t n; cin >> n; matrix->resize(n, vector<int>(n)); for (size_t i = 0; i < n; ++i) { ...
C++
#include<iostream> #include<vector> #include<algorithm> using std::vector; using std::pair; using std::make_pair; using std::swap; using std::cin; using std::cout; using std::iter_swap; template<typename T> pair<T, T> Partition(T left, T right, int mid) { while (left <= right) { while (*lef...
C++
#include<iostream> #include<algorithm> #include<vector> using std::vector; using std::pair; using std::make_pair; using std::swap; using std::cin; using std::cout; template<typename T> void Input(vector<T> &v, vector<T> &help) { size_t size; cin >> size; v.resize(size); help.resize(siz...
C++
#include<iostream> #include<algorithm> #include<vector> using std::vector; using std::pair; using std::make_pair; using std::swap; using std::cin; using std::cout; template<typename T> void Input(vector<T> &first, vector<T> &second, vector<T> &res) { int size_first; cin >> size_first; first...
C++
#include<iostream> #include<algorithm> #include<vector> using std::vector; using std::cin; using std::cout; using std::iter_swap; template<typename T> void Input(vector<T> &v) { size_t size; cin >> size; v.resize(size); for (size_t i = 0; i < size; ++i) { cin >> v[i]; } } ...
C++
#include<iostream> #include<algorithm> #include<vector> using std::vector; using std::cin; using std::cout; using std::iter_swap; template<typename T> void Input(vector<T> &v) { size_t size; cin >> size; v.resize(size); for (size_t i = 0; i < size; ++i) { cin >> v[i]; } } ...
C++
#include<iostream> #include<algorithm> #include<vector> using std::vector; using std::pair; using std::make_pair; using std::iter_swap; using std::cin; using std::cout; using std::endl; using std::distance; template <typename T> void Input(vector<T> &v, int &separator) { size_t size; cin >> si...
C++
#include<iostream> #include<vector> using std::cin; using std::cout; using std::vector; using std::endl; template<typename T> void Create_a_graph(int &n, int &a, int &b, vector<vector<T>> &v) { cin >> n; v.resize(2 * n); cin >> a >> b; for (int i = 0; i < a; ++i) { int first, sec...
C++
#include<iostream> #include<vector> #include<math.h> #include<algorithm> using std::cin; using std::cout; using std::vector; using std::endl; #define magic 268435459; template<typename T> void Input(vector<vector<T>> & table, vector<vector<T>> &count) { size_t n, m; cin >> n >> m; table.r...
C++
#include<iostream> #include<cstring> #include<string> #include<vector> #include<queue> using std::cin; using std::cout; using std::vector; using std::endl; using std::queue; template<typename T2> void Input(vector<vector<T2>> &g, T2 &start, T2 &fin) { int n, m; cin >> n; cin >> m; vec...
C++
#include<iostream> #include<vector> #include<math.h> #include<algorithm> using std::cin; using std::cout; using std::vector; using std::endl; template<typename T> void Input(vector<vector<T>> & table, vector<vector<T>> &cost) { size_t n, m; cin >> n >> m; table.resize(n), cost.resize(n); ...
C++
#include<iostream> #include<cstring> #include<string> #include<vector> #include<math.h> using std::cin; using std::cout; using std::vector; using std::endl; struct point { double x, y; }; double length(point a, point b) { return (sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y))); ...
C++
#include <iostream> #include <vector> using std::vector; using std::cin; using std::cout; enum color { WHITE, GREY, BLACK }; class AbstractDoer { public: virtual void entering(int vertex) {}; virtual void leaving(int vertex) {}; virtual void grey_edge(int from, int to) {} virtual void black_edge(int...
C++
#include <iostream> #include <vector> #include <algorithm> using std::cin; using std::cout; using std::endl; using std::vector; const int inf = 1e9; struct Station { int x, y; Station(int x = 0, int y = 0): x(x), y(y) {} friend std::istream& operator>>(std::istream& lin, Station& station) { lin ...
C++
#include <iostream> #include <vector> #include <algorithm> using std::cin; using std::cout; using std::vector; class AbstractDoer { public: virtual void entering(int vertex) {}; virtual void leaving(int vertex) {}; virtual void if_used(int from, int to) {} virtual void before_iteration(int from, int ...
C++
#include <iostream> #include <vector> #include <algorithm> #include <queue> using std::cin; using std::cout; using std::endl; using std::vector; const int inf = 1e9; struct Point { int x, y; Point(int x = 0, int y = 0): x(x), y(y) {} friend std::istream& operator>>(std::istream& lin, Point& point) { ...
C++
#include <iostream> #include <vector> using std::cin; using std::cout; using std::endl; using std::vector; const int inf = 1e9; int main() { vector<vector<int>> matrix; vector<vector<int>> dynamics; int n, m; cin >> n >> m; matrix.resize(n + 1); dynamics.resize(n + 1); for (int i = 0; i <...
C++
#include <iostream> #include <vector> using std::cin; using std::cout; using std::endl; using std::vector; const int inf = 1e9; int main() { vector<vector<int>> matrix; vector<vector<int>> dynamics; int n, m; cin >> n >> m; matrix.resize(n + 1); dynamics.resize(n + 1); for (int i = 0; i <...
C++
#include <iostream> #include <vector> #include <algorithm> template <typename T> void read_array(std::vector <T>* input_array) { int n; std::cin >> n; input_array->reserve(n); for (int i = 0; i < n; ++i) { T number; std::cin >> number; input_array->push_back(number); } } template...
C++
#include <iostream> #include <vector> template <typename InIt, typename OutIt> OutIt merge(InIt begin_left, InIt end_left, InIt begin_right, InIt end_right, OutIt dest) { auto it1 = begin_left, it2 = begin_right; while (it1 != end_left || it2 != end_right) { if (it2 == end_right || (it1 != end_left && ...
C++
#include <iostream> #include <vector> template <typename InIt> InIt my_partition(InIt first, InIt last, int x) { while (first != last) { while (*first < x) { ++first; if (first==last) return first; } do { --last; if (first==last) return first...
C++
#include <iostream> #include <vector> template <typename T> void move_max(T begin, T end) { if (begin == end) { return; } T maximum_position = begin; for (auto it = begin; it!= end; ++it) { if (*maximum_position < *it) { maximum_position = it; } } std::iter...
C++
#include <iostream> #include <vector> template <typename T> void move_max(T begin, T end) { if (begin == end) { return; } T maximum_position = begin; for (auto it = begin; it!= end; ++it) { if (*maximum_position < *it) { maximum_position = it; } } std::iter...
C++
#include <iostream> #include <vector> template <typename InIt, typename OutIt> OutIt merge(InIt begin_left, InIt end_left, InIt begin_right, InIt end_right, OutIt dest) { auto it1 = begin_left, it2 = begin_right; while (it1 != end_left || it2 != end_right) { if (it2 == end_right || (it1 != end_left && ...
C++
trash
C++
#include <iostream> #include <vector> #include <algorithm> using std::vector; using std::cin; using std::cout; int FindMax(vector<int> &v, int n) { int max_coor = 0; for (int i = 0; i < n; i++) { if (v[i] > v[max_coor]) { max_coor = i; } } return max_coor; } int main() { int n; cin >...
C++
#include <iostream> #include <vector> #include <algorithm> using std::vector; using std::cin; using std::cout; template <typename iter> iter partition(iter begin, iter end, int x) { if(end == begin) return begin; --end; while (begin != end) { if (*begin < x) { ++...
C++
#include <iostream> #include <vector> #include <algorithm> using std::vector; using std::cin; using std::cout; template <typename iter> void merge (iter first_begin, iter first_end, iter second_begin, iter second_end, iter buffer) { while (first_begin != first_end && second_begin != second_end) { ...
C++
#include <iostream> #include <vector> #include <algorithm> using std::vector; using std::cin; using std::cout; template <typename iter> void merge (iter first_begin, iter first_end, iter second_begin, iter second_end, iter buffer) { while (first_begin != first_end && second_begin != second_end) { ...
C++
#include <iostream> #include <vector> #include <algorithm> using std::vector; using std::cin; using std::cout; int FindMax(vector<int> &v, int n) { int max_coor = 0; for (int i = 0; i < n; i++) { if (v[i] > v[max_coor]) { max_coor = i; } } return max_coor; } int main() { int n; cin >...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::vector; using std::cin; using std::cout; template <typename iter> iter add_partition(iter begin, iter end, iter part, int x) { iter flag = part; while (begin != flag) { if (*begin == x) { std::swap(*b...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::vector; using std::cin; using std::cout; int din(int n, int m, vector<vector<int> > &dinamic, vector<vector<int> > &a) { if(n < 0 || m < 0) { return 1e+9; } if (dinamic[n][m] + 1) { retu...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::vector; using std::cin; using std::cout; void Input(int &n, int &k, vector<vector<int> > &matrix) { cin >> n >> k; vector<std::pair<int, int> > coordinates(n); for (int i = 0; i < n; ++i) { cin >> coordinate...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::vector; using std::cin; using std::cout; struct interval { int begin; int end; }; void Input(int &n, int &a, int &b, vector<vector<int> > &graf) { cin >> n >> a >> b; graf.resize(2 * n); // 2*i ...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <queue> using std::vector; using std::cin; using std::cout; void Input(int &n, int &m, vector<vector<int> > &matrix, int &x_start, int &y_start, int &x_finish, int &y_finish) { cin >> n >> m; matrix.resize(n); cin >> ...
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> using std::vector; using std::cin; using std::cout; long long din(int n, int m, vector<vector<long long> > &dinamic, vector<vector<long long> > &a) { if(n < 0 || m < 0) { return 0; } if (dinamic[n][m] + 1) ...
C++
#include <iostream> #include <random> #include <set> using namespace std; int generate() { while (true) { int n = rand() % 10000; int curr = n; set<int> numbers; while (curr) { numbers.insert(curr%10); curr /= 10; } if (numbers...
C++
#include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; using std::swap; void Input(vector <int> *list) { int count; cin >> count; list->reserve(count); int element; for (int i(0); i < count; ++i) { cin >> element; list->push_back(elem...
C++
#include <iostream> #include <vector> #include <ctime> using std::cin; using std::cout; using std::vector; using std::swap; using std::distance; void Input(vector <int> *list) { int count; cin >> count; list->reserve(count); int element; for (int i(0); i < count; ++i) { cin >...
C++