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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <map> | |
#include <cstdio> | |
using namespace std; | |
#define MAXN 101000 | |
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 <iostream> | |
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
#define MAXN 100100 | |
int p = 1; | |
int indextree[4*MAXN]; |
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 <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <cstdio> | |
using namespace std; | |
int indexTree[100001 * 4]; | |
int p = 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 <iostream> | |
#include <vector> | |
#include <cstdio> | |
using namespace std; | |
vector<int> tree; | |
vector<int> input; | |
vector<int> index_point; | |
int N, M; |
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 <iostream> | |
#include <stdio.h> | |
using namespace std; | |
int N, K; | |
int p = 1; | |
int A[500000*4]; | |
//구간 트리를 갱신하는 함수 | |
void part_update(int temp1){ |
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 <iostream> | |
#include <cstdio> | |
using namespace std; | |
#define MAXN 100005 | |
int N, K, indexTree[4*MAXN], arr[MAXN], p; | |
void init(){ | |
p = 1; | |
while(p < N) p <<= 1; | |
for(int i = 0 ; i < N ; i++) | |
indexTree[p+i] = arr[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
#include <iostream> | |
#include <cstdio> | |
using namespace std; | |
#define MAXN 1000100 | |
int p = 1; | |
int N, M, K, a, b, c; | |
long long indexTree[4 * MAXN]; |
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
vector<int> getPi(string p){ | |
int m = (int)p.size(), j=0; | |
vector<int> pi(m, 0); | |
for(int i = 1; i< m ; i++){ | |
while(j > 0 && p[i] != p[j]) | |
j = pi[j-1]; | |
if(p[i] == p[j]) | |
pi[i] = ++j; | |
} | |
return pi; |
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
vector<int> kmp(string s, string p){ | |
vector<int> ans; | |
auto pi = getPi(p); | |
int n = (int)s.size(), m = (int)p.size(), j =0; | |
for(int i = 0 ; i < n ; i++){ | |
while(j>0 && s[i] != p[j]) | |
j = pi[j-1]; | |
if(s[i] == p[j]){ | |
if(j==m-1){ | |
ans.push_back(i-m+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 <iostream> | |
#include <string> | |
#include <cstdio> | |
#include <vector> | |
using namespace std; | |
vector<int> getPi(string p){ | |
int m = (int)p.size(), j=0; | |
vector<int> pi(m, 0); | |
for(int i = 1; i< m ; i++){ | |
while(j > 0 && p[i] != p[j]) |