13713번: 문자열과 쿼리 - Z
Z 기본 문제.#include using namespace std;typedef long long ll;typedef pair pii;typedef pair pll;typedef tuple tll;const int MAXN = 1000001;string S, T;int N, M;int Z[MAXN]; //Z[i] : S와 S[i...N-1]와의 공통 접두사의 길이int F[MAXN];int main(){ ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> S; N = S.size(); for(int i=N-1; i>=0; i--) T += S[i]; //구하고자 하는 답은 문자열을 뒤집은 답의 Z 배열이다. int l = 0, r = 0; //최대 공..
알고리즘/baekjoon
2024. 7. 20. 23:48