View smawk.cpp
This file contains 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> | |
#define sz(v) ((int)(v).size()) | |
#define all(v) (v).begin(), (v).end() | |
using namespace std; | |
using lint = long long; | |
using llf = long double; | |
using pi = array<int, 2>; | |
// Let a matrix be monotone if Opt(i) <= Opt(i + 1) for all rows i. | |
// Given a totally monotone matrix (where every 2x2 submatrix is monotone), find the list of row optima positions. |
View boj12795.cpp
This file contains 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; | |
using pi = pair<int, int>; | |
using lint = long long; | |
#define sz(v) ((int)(v).size()) | |
#define all(v) (v).begin(), (v).end() | |
const int MAXT = 530000; | |
const lint inf = 4e18; | |
struct line { |
View berlekamp_massey.cpp
This file contains 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
const int mod = 998244353; | |
using lint = long long; | |
lint ipow(lint x, lint p){ | |
lint ret = 1, piv = x; | |
while(p){ | |
if(p & 1) ret = ret * piv % mod; | |
piv = piv * piv % mod; | |
p >>= 1; | |
} | |
return ret; |
View mirror.cpp
This file contains 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> | |
const int MAXN = 100005; | |
using namespace std; | |
using lint = long long; | |
typedef pair<lint, lint> pi; | |
typedef long long lint; | |
struct seg{ | |
int x, l, r, num; | |
}; |
View mirror.cpp
This file contains 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> | |
const int MAXN = 100005; | |
using namespace std; | |
using lint = long long; | |
typedef pair<lint, lint> pi; | |
typedef long long lint; | |
struct seg{ | |
int x, l, r, num; | |
}; |
View mirror.cpp
This file contains 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> | |
const int MAXN = 100005; | |
using namespace std; | |
using lint = long long; | |
typedef pair<lint, lint> pi; | |
typedef long long lint; | |
struct seg{ | |
int x, l, r, num; | |
}; |
View euler_tour.cpp
This file contains 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 <cstdio> | |
#include <vector> | |
using namespace std; | |
vector<int> v; | |
int n,adj[1005][1005]; | |
void f(int x){ | |
for (int i=1; i<=n; i++) { | |
if(adj[x][i]){ |
View greedy.cpp
This file contains 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
int dfs(int x, int p){ | |
vector<int> e; | |
for(auto &i : tr[x]){ | |
if(i == p) continue; | |
e.push_back(dfs(i, x)); | |
} | |
if(e.empty()) return 1; | |
sort(e.begin(), e.end()); | |
for(int i=0; i<e.size()-1; i++){ | |
v.push_back(e[i]); |
View ahocorasick.cpp
This file contains 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
const int MAXN = 100005, MAXC = 26; | |
struct aho_corasick{ | |
int trie[MAXN][MAXC], piv; // trie | |
int fail[MAXN]; // failure link | |
int term[MAXN]; // output check | |
void init(vector<string> &v){ | |
memset(trie, 0, sizeof(trie)); | |
memset(fail, 0, sizeof(fail)); | |
memset(term, 0, sizeof(term)); |
View fb17r3a.cpp
This file contains 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 lint; | |
typedef pair<int, int> pi; | |
const int mod = 1e9 + 7; | |
int rev[1005], sfx[1005]; | |
char str[1005]; | |
int n; |
NewerOlder