hiho Week 3 register

Ended

Participants:669

Verdict:Accepted
Submitted:2014-07-23 01:09:37

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <string>
using namespace std;
const int Msize=1000000;
const int msize=10000;
string s, ss;
int next[msize];
int main()
{
    int n;
    cin >> n;
    getline(cin, s);
    for (int i=0; i<n; ++i)
    {
        int ans=0;
        getline(cin, s);
        getline(cin, ss);
        int len=s.length();
        int j=-1;
        next[0]=j;
        for (int i=1; i<len; ++i)
        {
              while ((j>-1)&&(s[i]!=s[j+1])) j=next[j];
              if (s[i]==s[j+1]) ++j;
              next[i]=j;
        }
        int Len=ss.length();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX