Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- #include <iomanip>
- #include <fstream>
- #include <string>
- #include <set>
- #include <deque>
- #include <queue>
- #include <map>
- #include <bitset>
- #include <random>
- #include <cassert>
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- #define sqrt sqrtl
- #define endl "\n"
- #define all(a) a.begin(), a.end()
- #define pb push_back
- #define f1 first
- #define s2 second
- const ll inf = 1e9;
- long double eps = 1e-18;
- ll mod = 1e9 + 7;
- const ll MAXN = 100010;
- const ll M = 1e9 + 7, m = 998244353;
- ll bb = 997;
- template <typename T>
- istream& operator >> (istream& in, vector <T>& a) {
- for (T& i : a) {
- in >> i;
- }
- return in;
- }
- template <typename T>
- ostream& operator << (ostream& out, vector <T>& a) {
- for (T& i : a) {
- out << i << ' ';
- }
- return out;
- }
- struct node{
- ll next[26];
- node(){
- for (ll i = 0; i < 26; i++) next[i] = 0;
- }
- };
- vector<node> bor(1);
- void build_bor(string &s) {
- for (ll i = 0; i < s.size(); i++) {
- ll now = 0;
- for (ll j = i; j < s.size(); j++) {
- char term = s[j] - 'a';
- if (bor[now].next[term] == 0) {
- bor[now].next[term] = bor.size();
- node vert;
- bor.push_back(vert);
- }
- now = bor[now].next[term];
- }
- }
- }
- void solve() {
- string s;
- cin >> s;
- build_bor(s);
- cout << bor.size()-1;
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- ll t = 1;
- //cin >> t;
- while (t--) solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement