백준
백준 소스코드 [C++] 1701 Cubeditor
Hani_Levenshtein
2021. 2. 17. 15:55
1701번: Cubeditor
Cubelover는 프로그래밍 언어 Whitespace의 코딩을 도와주는 언어인 Cubelang을 만들었다. Cubelang을 이용해 코딩을 하다보니, 점점 이 언어에 맞는 새로운 에디터가 필요하게 되었다. 오랜 시간 고생한
www.acmicpc.net
백준 소스코드 [C++] 1701 Cubeditor
#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <limits.h>
#include <vector>
#include <math.h>
#include <stack>
#include <bitset>
#include <string>
#include <set>
#define all(v) v.begin(), v.end()
#define pii pair<int,int>
#define make_unique(v) v.erase(unique(v.begin(), v.end()), v.end())
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
vector<int> v(s.size());
int res = 0;
for (int i = 0;i < s.size();i++) {
for (int j = 0;j < s.size();j++)
v[j] = i;
for (int j = i + 1, k = i;j < s.size();j++) {
while (k > i && s[j] != s[k])
k = v[k - 1];
if (s[j] == s[k]) {
v[j] = ++k;
res = max(res, k-i);
}
}
}
cout << res;
return 0;
}