“HihoCoder 1014” Trie tree

The title is direct. Subject matter I’ll give you a $n$string. Save it in a dictionary. Here’s another $m for each query, one string for each query, and in the dictionary, find out how many strings are prefixed with this string.   The idea of solving the problem Template problem Setting a variable of $sig $at each point indicates the number of words prefixed with strings of characters passing through the path. $Trie$ Tree. In $insert$operation, add $sig$to the point passed through the path $1$. $sig$is directly output when querying. Attach the code #include <iostream> #in...

「 HDOJ P3336 」 Count the string

Subject matter Given a string of $s$which is $n in length, you are asked to find the sum of the times each prefix of $s$appears in $s$. $n\le 200000$.   The idea of solving the problem The violence prefix each prefix and match the number of occurrences. That certainly won’t work. The complexity is $O (n\ times (m + n) $and we don’t have to worry about TLE, but let’s consider the nature of the $next $array in $KMP $for each prefix and the longest common substring for each prefix. That doesn’t mean that if $next [i] = J $then the two substrings of $1 right arrow J $and ...

polymorphic

1. Polymorphic definition:   1.There must be an inheritance relationship.   2.There must be a way to rewrite.   3.The parent class refers to a subclass object. Two, the characteristics of member access in polymorphism (parent f = new child).   A:Member variables: compile the left side, run to the left;   B:Constructor: When creating subclass objects, access the constructor of the parent class and initialize the data of the parent class.   C:Member method: compile the left side, run to the right.   D:Static method: compile the left side, run to the left. Thr...

exception handling

I. what is abnormal?   An exception is a signal that something is wrong when the program is running (an exception is generated when the program is wrong, and if the program is not handling it, the exception is thrown, and the program runs with it) And mistakes fall into two categories.   1Syntax errors (such errors, which can’t pass the syntax checking of the Python interpreter at all, must be corrected before the program executes) #TypeError:intType is not iterative. for i in 3: pass #ValueError num=input(">>: ") #Input hello int(num) #NameError aaa #IndexError l=['e...

Nlogn LIS template

nlogn Template #include<bits/stdc++.h> using namespace std; const int N=100050; int n,x,y,a[N],num[N],d[N],len; /* int binary_search(int i){ int left,right,mid; left=0,right=len; while(left<right){ mid = left+(right-left)/2; if(ans[mid]>=arr[i]) right=mid; else left=mid+1; } return left; } */ int main(){ //LCSConvert into LIS ios::sync_with_stdio(false); cin>>n; for(int i=1;i<=n;i++) cin>>x,num[x]=i; for(int i=1;i<=n;i++) cin>>y,a[i]=num[y]; //nlogn LIS d[...

Sina blog forward crawl

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"> </head> <body style="background-color: gray;"> <div class="container"> <form method="get"> <h4>Your cookie:< /h4>< textarea name= "cookie"class="form-control" rows="3" placeholder="Your cookie will be pasted in the debug, "> < /textarea>".< h4> a micro-blog id:< /h4>< inputNa...