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 <numeric> | |
#include <algorithm> | |
#include <cstring> | |
using namespace std; | |
int T, m, S, S2; | |
int ctype[40][2]; | |
int memo[300][300]; | |
//smallest amount of e-coins needed | |
int way(int a, int b){ |
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 <numeric> | |
#include <cstdio> | |
#include <algorithm> | |
#include <cstring> | |
using namespace std; | |
int T,N,M,K; | |
int strip[128][128]; | |
// s k | |
// |-+-+-+-+-+ |
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 <algorithm> | |
#include <cstdio> //sscanf | |
#include <string> //getline, c_str() | |
#include <iostream> //cin | |
using namespace std; | |
int t, n, l1, l2; | |
int main(){ | |
int i=1; | |
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 <set> | |
#include <unordered_set> | |
#include <algorithm> | |
#include <utility> | |
#include <cstdio> | |
#include <map> | |
using namespace std; | |
typedef pair<int, int> pii; | |
const long long mod = 1000000009; | |
int m, x, y; |
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 <vector> | |
#include <string> | |
#include <iostream> | |
#include <map> | |
#include <set> | |
#include <queue> | |
#include <functional> | |
#include <cstring> //memset | |
using namespace std; |
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
/* Note we compare both first and second element. If we only compare the first, inserting with equal key will fail. | |
* e.g. {4,5} {4,6} will only insert {4,5} although {4,6} is also a valid pair we want here. | |
*/ | |
auto comp = [](const ii &l, const ii &r) {return l.first==r.first?l.second<r.second:l.first<r.first;}; | |
/* | |
* Use decltype to inspects the declared type of an entity or queries the return type of an expression. | |
*/ | |
set<ii, decltype(comp)> bridges(comp); |
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 <iostream> | |
#include <algorithm> | |
#include <cstdlib> | |
#include <set> | |
#include <string> | |
#include <map> | |
#include <functional> | |
using namespace std; | |
int V1, V2, T, D; | |
int bt(int v, int level, int sum){ |
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
/* | |
* updown /\ up / down \ | |
* / \ / \ | |
* / \ / \ | |
* v1 v2 v1 v2 | |
*/ | |
int ans=v1+v2; | |
t-=2; | |
REP(k,t){ |
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
void gen_primes() { | |
int i,j; | |
for(i=0;i<MAX;i++) primes[i] = 1; | |
for(i=2;i<=(int)sqrt(MAX);i++) | |
if (primes[i]) | |
for(j=i;j*i<MAX;j++) primes[i*j] = 0; | |
} |
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
//http://e-maxx-eng.github.io/string/z-function.html | |
vector<int> z_alg(string s){ | |
int n=s.size(); | |
vector<int> v(n, 0); | |
for(int i=1, l=0, r=0;i<n;++i){ | |
if(i<=r){ // we can use the already calcuated z-value to "init" the v[i] | |
v[i]=min(v[i-l], r-i+1); // I-L not i-1 | |
} | |
else{ // i>r trivial bf | |
while(i+v[i]<n && s[v[i]]==s[i+v[i]]) |
OlderNewer