zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 41 (Rated for Div. 2) ABCDEF

    最近打的比较少。。。就只有这么点题解了。

    A. Tetris
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You are given a following process.

    There is a platform with n columns. 1 × 1 squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest square of this column.

    When all of the n columns have at least one square in them, the bottom row is being removed. You will receive 1 point for this, and all the squares left will fall down one row.

    You task is to calculate the amount of points you will receive.

    Input

    The first line of input contain 2 integer numbers n and m (1 ≤ n, m ≤ 1000) — the length of the platform and the number of the squares.

    The next line contain m integer numbers c1, c2, ..., cm (1 ≤ ci ≤ n) — column in which i-th square will appear.

    Output

    Print one integer — the amount of points you will receive.

    Example
    input
    Copy
    3 9
    1 1 2 2 2 3 1 2 3
    output
    2


    题意:类似俄罗斯方块,不过每次只降下一个1*1的方块。给出列数,还有每次方块降下所在的列,求能消除几列。

    题解:算每列方块数然后求最小值。

     1 #include<bits/stdc++.h>
     2 #define clr(x) memset(x,0,sizeof(x))
     3 #define INF 0x3f3f3f3f
     4 using namespace std;
     5 const int N=1e3+10;
     6 int a[N],n,m,d,minx;
     7 int main()
     8 {
     9     scanf("%d%d",&n,&m);
    10     for(int i=1;i<=m;i++)
    11     {
    12         scanf("%d",&d);
    13         a[d]++;
    14     }
    15     minx=INF;
    16     for(int i=1;i<=n;i++)
    17         minx=min(minx,a[i]);
    18     printf("%d
    ",minx);
    19     return 0;
    20 }
    View Code
    B. Lecture Sleep
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells ai theorems during the i-th minute.

    Mishka is really interested in calculus, though it is so hard to stay awake for all the time of lecture. You are given an array t of Mishka's behavior. If Mishka is asleep during the i-th minute of the lecture then ti will be equal to 0, otherwise it will be equal to 1. When Mishka is awake he writes down all the theorems he is being told — ai during the i-th minute. Otherwise he writes nothing.

    You know some secret technique to keep Mishka awake for k minutes straight. However you can use it only once. You can start using it at the beginning of any minute between 1 and n - k + 1. If you use it on some minute i then Mishka will be awake during minutes j such that  and will write down all the theorems lecturer tells.

    You task is to calculate the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.

    Input

    The first line of the input contains two integer numbers n and k (1 ≤ k ≤ n ≤ 105) — the duration of the lecture in minutes and the number of minutes you can keep Mishka awake.

    The second line of the input contains n integer numbers a1, a2, ... an (1 ≤ ai ≤ 104) — the number of theorems lecturer tells during the i-th minute.

    The third line of the input contains n integer numbers t1, t2, ... tn (0 ≤ ti ≤ 1) — type of Mishka's behavior at the i-th minute of the lecture.

    Output

    Print only one integer — the maximum number of theorems Mishka will be able to write down if you use your technique only once to wake him up.

    Example
    input
    Copy
    6 3
    1 3 5 2 5 4
    1 1 0 1 0 0
    output
    16
    Note

    In the sample case the better way is to use the secret technique at the beginning of the third minute. Then the number of theorems Mishka will be able to write down will be equal to 16.


    题意:第一行给出长度为n的价值序列,以及第二行可否获取的01序列,你可以最多把01序列里面连续k个置为1,问最多能获得多少价值。

    题解:可获取的序列a[i]直接加入贡献,并置a[i]为0。然后求a[i]前缀和pre[i],找一个最大的pre[i]-pre[i-k]加入贡献,这样的贡献即为答案。

     1 #include<bits/stdc++.h>
     2 #define clr(x) memset(x,0,sizeof(x))
     3 #define INF 0x3f3f3f3f
     4 using namespace std;
     5 const int N=1e5+10;
     6 int a[N],t,n,m,d,maxn,k,ans,now;
     7 int main()
     8 {
     9     scanf("%d%d",&n,&k);
    10     for(int i=1;i<=n;i++)
    11         scanf("%d",a+i);
    12     for(int i=1;i<=n;i++)
    13     {
    14          scanf("%d",&t);
    15          if(t)
    16          {
    17              ans+=a[i];
    18              a[i]=0;
    19          }
    20     }
    21     for(int i=1;i<=k && i<=n;i++)
    22         now+=a[i];
    23     maxn=now;
    24     for(int i=k+1;i<=n;i++)
    25     {
    26         now-=a[i-k];
    27         now+=a[i];
    28         maxn=max(maxn,now);
    29     }
    30     ans+=maxn;
    31     printf("%d
    ",ans);
    32     return 0;
    33 
    34 }
    View Code
    C. Chessboard
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Magnus decided to play a classic chess game. Though what he saw in his locker shocked him! His favourite chessboard got broken into 4pieces, each of size n by nn is always odd. And what's even worse, some squares were of wrong color. j-th square of the i-th row of k-th piece of the board has color ak, i, j1 being black and 0 being white.

    Now Magnus wants to change color of some squares in such a way that he recolors minimum number of squares and obtained pieces form a valid chessboard. Every square has its color different to each of the neightbouring by side squares in a valid board. Its size should be 2n by2n. You are allowed to move pieces but not allowed to rotate or flip them.

    Input

    The first line contains odd integer n (1 ≤ n ≤ 100) — the size of all pieces of the board.

    Then 4 segments follow, each describes one piece of the board. Each consists of n lines of n characters; j-th one of i-th line is equal to 1 if the square is black initially and 0 otherwise. Segments are separated by an empty line.

    Output

    Print one number — minimum number of squares Magnus should recolor to be able to obtain a valid chessboard.

    Examples
    input
    Copy
    1
    0

    0

    1

    0
    output
    1
    input
    Copy
    3
    101
    010
    101

    101
    000
    101

    010
    101
    011

    010
    101
    010
    output
    2

    题意:有一个黑白相间的棋盘碎成4个n*n的块,而且其上的颜色沾污了,不一定是黑白相间的。现在让你把这4个块染色,给块中一格染色需要付出代价1。现在让你求使得这四块能拼成一个黑白相间的棋盘所需付出的最小代价。

    题解:每个块染色后都有两种样式,分别对应左上角为黑或白。我们把每块变为这两种样式所需代价求出,然后枚举所有的4个块拼成棋盘的组合,找出最小的代价即为答案。

     1 #include<bits/stdc++.h>
     2 #define clr(x) memset(x,0,sizeof(x))
     3 #define INF 0x3f3f3f3f
     4 using namespace std;
     5 const int N=1e5+10;
     6 int need[5][2],n,m,ans;
     7 char s[N];
     8 int main()
     9 {
    10     scanf("%d",&n);
    11     for(int i=1;i<=4;i++)
    12     {
    13         for(int j=1;j<=n;j++)
    14         {
    15             scanf("%s",s);
    16             for(int k=0;k<n;k++)
    17             {
    18                 m=s[k]-'0';
    19                 need[i][(k&1)^(j&1)^m]++;
    20             }
    21         }
    22     }
    23     ans=INF;
    24     for(int i=1;i<=4;i++)
    25         for(int j=1;j<=4;j++)
    26             if(j!=i)
    27                 for(int k=1;k<=4;k++)
    28                     if(k!=j && k!=i)
    29                         for(int l=1;l<=4;l++)
    30                             if(l!=k && l!=j && l!=i)
    31                             {
    32                                 ans=min(ans,need[i][0]+need[j][0]+need[k][1]+need[l][1]);
    33                             }
    34     printf("%d
    ",ans);
    35     return 0;
    36 }
    View Code
    D. Pair Of Lines
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You are given n points on Cartesian plane. Every point is a lattice point (i. e. both of its coordinates are integers), and all points are distinct.

    You may draw two straight lines (not necessarily distinct). Is it possible to do this in such a way that every point lies on at least one of these lines?

    Input

    The first line contains one integer n (1 ≤ n ≤ 105) — the number of points you are given.

    Then n lines follow, each line containing two integers xi and yi (|xi|, |yi| ≤ 109)— coordinates of i-th point. All n points are distinct.

    Output

    If it is possible to draw two straight lines in such a way that each of given points belongs to at least one of these lines, print YES. Otherwise, print NO.

    Examples
    input
    Copy
    5
    0 0
    0 1
    1 1
    1 -1
    2 2
    output
    YES
    input
    Copy
    5
    0 0
    1 0
    2 1
    1 1
    2 3
    output
    NO
    Note

    In the first example it is possible to draw two lines, the one containing the points 1, 3 and 5, and another one containing two remaining points.

     


    题意:给你一堆整数点,然后让你判断是否能最多只画两条直线,使得这两条直线经过所有点。

    题解:先找到互不在同一直线上的三个点。然后枚举其中两个点连线,为其中一条直线。另外一个点找不在这条直线上的另一个点连线(用向量积),构成另外一条直线。然后检查所有点是不是在这两条线上,如果是的话就输出YES反之输出NO。

     1 #include<bits/stdc++.h>
     2 #define clr(x) memset(x,0,sizeof(x))
     3 #define ll long long
     4 using namespace std;
     5 const int maxn=1e5+100;
     6 struct node{
     7     int x,y;
     8 }p[maxn];
     9 int res[5];
    10 int n;
    11 void Read(){
    12     scanf("%d",&n);
    13     for(int i=1;i<=n;i++){
    14         scanf("%d%d",&p[i].x,&p[i].y);
    15     }
    16 }
    17 bool judge(int a,int b){
    18     int ans=0;
    19     while(ans==a||ans==b) ans++;
    20     int y1=p[res[b]].y-p[res[a]].y;
    21     int x1=p[res[b]].x-p[res[a]].x;
    22     int x2,y2;
    23     bool flag=true;
    24     for(int i=1;i<=n;i++){
    25         int y=p[i].y-p[res[a]].y;
    26         int x=p[i].x-p[res[a]].x;
    27         if(1LL*y1*x==1LL*x1*y)continue;
    28         y=p[i].y-p[res[ans]].y;
    29         x=p[i].x-p[res[ans]].x;
    30         if(flag&&i!=res[ans]){
    31             y2=y;x2=x;flag=false;
    32         }
    33         else{
    34             if(y2*x==x2*y)continue;
    35             return false;
    36         }
    37     }
    38     return true;
    39 }
    40 int main()
    41 {
    42     Read();
    43     if(n<=3){
    44         printf("YES
    ");
    45         return 0;
    46     }
    47     int y1=p[2].y-p[1].y;
    48     int x1=p[2].x-p[1].x;
    49     int flag=0;
    50     int i=3;
    51     for(;i<=n;i++){
    52         int y=p[i].y-p[1].y;
    53         int x=p[i].x-p[1].x;
    54         if(1LL*y1*x==1LL*x1*y)
    55             continue;
    56         else{
    57             flag=1;
    58             break;
    59         }
    60     }
    61     if(!flag){
    62         printf("YES
    ");
    63         return 0;
    64     }
    65     res[0]=1,res[1]=2,res[2]=i;
    66     for(i=0;i<3;i++)
    67         for(int j=i+1;j<3;j++)
    68             if(judge(i,j)){
    69                 printf("YES
    ");
    70                 return 0;
    71             }
    72     printf("NO
    ");
    73     return 0;
    74 }
    View Code
    E. Tufurama
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series "Tufurama". He was pretty surprised when he got results only for season 7 episode 3 with his search query of "Watch Tufurama season 3 episode 7 online full hd free". This got Polycarp confused — what if he decides to rewatch the entire series someday and won't be able to find the right episodes to watch? Polycarp now wants to count the number of times he will be forced to search for an episode using some different method.

    TV series have n seasons (numbered 1 through n), the i-th season has ai episodes (numbered 1 through ai). Polycarp thinks that if for some pair of integers x and y (x < y) exist both season x episode y and season y episode x then one of these search queries will include the wrong results. Help Polycarp to calculate the number of such pairs!

    Input

    The first line contains one integer n (1  ≤ n  ≤  2·105) — the number of seasons.

    The second line contains n integers separated by space a1, a2, ..., an (1 ≤ ai ≤ 109) — number of episodes in each season.

    Output

    Print one integer — the number of pairs x and y (x < y) such that there exist both season x episode y and season y episode x.

    Examples
    input
    Copy
    5
    1 2 3 4 5
    output
    0
    input
    Copy
    3
    8 12 7
    output
    3
    input
    Copy
    3
    3 2 1
    output
    2
    Note

    Possible pairs in the second example:

    1. x = 1, y = 2 (season 1 episode 2  season 2 episode 1);
    2. x = 2, y = 3 (season 2 episode 3  season 3 episode 2);
    3. x = 1, y = 3 (season 1 episode 3  season 3 episode 1).

    In the third example:

    1. x = 1, y = 2 (season 1 episode 2  season 2 episode 1);
    2. x = 1, y = 3 (season 1 episode 3  season 3 episode 1).

     题意,给出一些季度和每季度的最高章节数,现在让你找存在总点对数。其中如若存在第x季度的第y章节及第y季度的第x章节(x<y),那么(x,y)算作一对。

    题解:写一个主席树,对于每个i,在a[i](a[i]若>n,a[i]=n)处权值+1。然后对于每个i,查询其第i+1~a[i]棵树间[i,n]的权值总和,加入答案。

     1 #include<bits/stdc++.h>
     2 #define clr(x) memset(x,0,sizeof(x))
     3 #define INF 0x3f3f3f3f
     4 #define LL long long
     5 using namespace std;
     6 const int N=2e5+10;
     7 struct seg
     8 {
     9     int l,r;
    10     int sum;
    11     int lt,rt;
    12 }tree[N<<5];
    13 int root[N],cnt,n,a[N];
    14 LL ans;
    15 void init(int &i,int l,int r)
    16 {
    17     tree[++cnt]=(seg){l,r};
    18     i=cnt;
    19     if(l==r)
    20         return ;
    21     int mid=(l+r)>>1;
    22     init(tree[i].lt,l,mid);
    23     init(tree[i].rt,mid+1,r);
    24     return ;
    25 }
    26 void update(int &i,int pos,int val)
    27 {
    28     tree[++cnt]=tree[i];
    29     i=cnt;
    30     tree[i].sum+=val;
    31     if(tree[i].l==tree[i].r)
    32         return ;
    33     int mid=(tree[i].l+tree[i].r)>>1;
    34     if(pos<=mid)
    35         update(tree[i].lt,pos,val);
    36      else
    37         update(tree[i].rt,pos,val);
    38      return ;
    39 }
    40 int query(int &i,int &j,int l,int r)
    41 {
    42     if(tree[i].l>=l && tree[i].r<=r)
    43         return tree[j].sum-tree[i].sum;
    44     int mid=(tree[i].l+tree[i].r)>>1;
    45     int ans=0;
    46     if(l<=mid)
    47         ans+=query(tree[i].lt,tree[j].lt,l,r);
    48     if(r>mid)
    49         ans+=query(tree[i].rt,tree[j].rt,l,r);
    50     return ans;
    51 }
    52 int main()
    53 {
    54     scanf("%d",&n);
    55     init(root[0],1,n);
    56     for(int i=1;i<=n;i++)
    57     {
    58         scanf("%d",a+i);
    59         if(a[i]>n) a[i]=n;
    60         update(root[i]=root[i-1],a[i],1);
    61     }
    62     for(int i=1;i<=n;i++)
    63     if(a[i]>i)
    64     {
    65         ans+=1LL*query(root[i],root[a[i]],i,n);
    66     }
    67     printf("%I64d
    ",ans);
    68     return 0;
    69 }
    View Code
    F. k-substrings
    time limit per test
    4 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    You are given a string s consisting of n lowercase Latin letters.

    Let's denote k-substring of s as a string subsk = sksk + 1..sn + 1 - k. Obviously, subs1 = s, and there are exactly  such substrings.

    Let's call some string t an odd proper suprefix of a string T iff the following conditions are met:

    • |T| > |t|;
    • |t| is an odd number;
    • t is simultaneously a prefix and a suffix of T.

    For evey k-substring () of s you have to calculate the maximum length of its odd proper suprefix.

    Input

    The first line contains one integer n (2 ≤ n ≤ 106) — the length s.

    The second line contains the string s consisting of n lowercase Latin letters.

    Output

    Print  integers. i-th of them should be equal to maximum length of an odd proper suprefix of i-substring of s (or  - 1, if there is no such string that is an odd proper suprefix of i-substring).

    Examples
    input
    Copy
    15
    bcabcabcabcabca
    output
    Copy
    9 7 5 3 1 -1 -1 -1
    input
    Copy
    24
    abaaabaaaabaaabaaaabaaab
    output
    Copy
    15 13 11 9 7 5 3 1 1 -1 -1 1
    input
    Copy
    19
    cabcabbcabcabbcabca
    output
    Copy
    5 3 1 -1 -1 1 1 -1 -1 -1
    Note

    The answer for first sample test is folowing:

    • 1-substring: bcabcabcabcabca
    • 2-substring: cabcabcabcabc
    • 3-substring: abcabcabcab
    • 4-substring: bcabcabca
    • 5-substring: cabcabc
    • 6-substring: abcab
    • 7-substring: bca
    • 8-substring: c

    POI2012的一道原题Prefixuffix差不多,题解就不多说了,拿hash写写就能过了。

    蟹蟹clairs的提点。顺便学了字符串hash。

     1 #include<bits/stdc++.h>
     2 #define clr(x) memset(x,0,sizeof(x))
     3 #define clr_1(x) memset(x,-1,sizeof(x))
     4 #define LL long long
     5 //usually mod num is 1004535809 99824435 1000000007
     6 #define pnum 233
     7 #define INF 0x3f3f3f3f
     8 #
     9 using namespace std;
    10 const int N=1e6+10;
    11 int f[N],power[N][2],hashx[N][2],mod[2]={1004535809,99824435};
    12 inline int gethashx(int l,int r,int x)
    13 {
    14     return (hashx[r][x]-(LL)hashx[l-1][x]*power[r-l+1][x]%mod[x]+mod[x])%mod[x];
    15 }
    16 inline bool check(int x,int y,int len)
    17 {
    18     return gethashx(x,x+len-1,0)==gethashx(y,y+len-1,0) && gethashx(x,x+len-1,1)==gethashx(y,y+len-1,1);
    19 }
    20 int n,ans;
    21 char s[N];
    22 int main()
    23 {
    24     scanf("%d",&n);
    25     scanf("%s",s);
    26     power[0][0]=power[0][1]=1;
    27     hashx[0][0]=hashx[0][1]=0;
    28     for(int i=1;i<=n;i++)
    29         for(int j=0;j<2;j++)
    30         {
    31             power[i][j]=(LL)power[i-1][j]*pnum%mod[j];
    32             hashx[i][j]=((LL)hashx[i-1][j]*pnum+(s[i-1]-'a'))%mod[j];
    33         }
    34     for(int i=(n+1)/2;i>=1;i--)
    35     {
    36         f[i]=min(f[i+1]+2,n-2*i+1);
    37         if(!(f[i]&1))
    38             f[i]--;
    39         while(f[i]>0 && !check(i,n-i-f[i]+2,f[i])) f[i]-=2;
    40     }
    41     for(int i=1;i<=(n+1)/2;i++)
    42         printf("%d ",f[i]);
    43     printf("
    ");
    44     return 0;
    45 }
    View Code

     另外一种方法就是求后缀数组+LCP+ST,这个麻烦点。两者区别就在于求子串相等部分的处理。

      1 #include<bits/stdc++.h>
      2 #define clr(x) memset(x,0,sizeof(x))
      3 #define clr_1(x) memset(x,-1,sizeof(x))
      4 #define LL long long
      5 #define mod 1000000007
      6 #define INF 0x3f3f3f3f
      7 #define F(x) ((x) / 3 + ((x) % 3 == 1 ? 0 : tb))
      8 #define G(x) ((x) < tb ? (x) * 3 + 1 : ((x) - tb) * 3 + 2)
      9 using namespace std;
     10 const int N=1e6+10;
     11 int wa[N],wb[N],backet[N],order[N],sa[N*3];
     12 int ranked[N],height[N],s[N*3],n,f[N];
     13 char str[N];
     14 int c0(int *r,int a,int b)
     15 {
     16     return r[a]==r[b]&&r[a+1]==r[b+1]&&r[a+2]==r[b+2];
     17 }
     18 int c12(int k,int *r,int a,int b)
     19 {
     20     if(k==2) return r[a]<r[b]||r[a]==r[b]&&c12(1,r,a+1,b+1);
     21     else return r[a]<r[b]||r[a]==r[b]&&order[a+1]<order[b+1];
     22 }
     23 void sorted(int *r,int *a,int *b,int n,int m)
     24 {
     25     int i;
     26     for(i=0;i<n;i++) order[i]=r[a[i]];
     27     for(i=0;i<m;i++) backet[i]=0;
     28     for(i=0;i<n;i++) backet[order[i]]++;
     29     for(i=1;i<m;i++) backet[i]+=backet[i-1];
     30     for(i=n-1;i>=0;i--) b[--backet[order[i]]]=a[i];
     31     return;
     32 }
     33 void dc3(int *r,int *sa,int n,int m)
     34 {
     35     int i,j,*san=sa+n,ta=0,tb=(n+1)/3,tbc=0,p;
     36     int *rn=r+n;
     37     r[n]=r[n+1]=0;
     38     for(i=0;i<n;i++) if(i%3!=0) wa[tbc++]=i;
     39     sorted(r+2,wa,wb,tbc,m);
     40     sorted(r+1,wb,wa,tbc,m);
     41     sorted(r,wa,wb,tbc,m);
     42     for(p=1,rn[F(wb[0])]=0,i=1;i<tbc;i++)
     43         rn[F(wb[i])]=c0(r,wb[i-1],wb[i])?p-1:p++;
     44     if(p<tbc) dc3(rn,san,tbc,p);
     45     else for(i=0;i<tbc;i++) san[rn[i]]=i;
     46     for(i=0;i<tbc;i++) if(san[i]<tb) wb[ta++]=san[i]*3;
     47     if(n%3==1) wb[ta++]=n-1;
     48     sorted(r,wb,wa,ta,m);
     49     for(i=0;i<tbc;i++) order[wb[i]=G(san[i])]=i;
     50     for(i=0,j=0,p=0;i<ta && j<tbc;p++)
     51         sa[p]=c12(wb[j]%3,r,wa[i],wb[j])?wa[i++]:wb[j++];
     52     for(;i<ta;p++) sa[p]=wa[i++];
     53     for(;j<tbc;p++) sa[p]=wb[j++];
     54     return;
     55 }
     56 void calheight(int *r, int *sa, int n) {
     57     int i, j, k = 0;
     58     for (i = 1; i <= n; i++) ranked[sa[i]] = i;
     59     for (i = 0; i < n; height[ranked[i++]] = k)
     60         for (k ? k-- : 0, j = sa[ranked[i] - 1]; r[i + k] == r[j + k]; k++);
     61     return ;
     62 }
     63 int st[N][21];
     64 void calmin(int n)
     65 {
     66     int t=0,k,divk;
     67     for(int i=1;i<n;i++)
     68         st[i][1]=height[i+1];
     69     for(k=4,t=2,divk=2;k<=n;k<<=1,divk<<=1,t++)
     70         for(int i=1;i<=n-k+1;i++)
     71             st[i][t]=min(min(st[i][t-1],st[i+divk][t-1]),height[i+divk]);
     72     return ;
     73 }
     74 int getmin(int u,int v)
     75 {
     76     u=ranked[u];
     77     v=ranked[v];
     78     if(u>v) swap(u,v);
     79     int p=v-u+1,k=0;
     80     while(p)
     81     {
     82         p>>=1;
     83         k++;
     84     }
     85     return min(st[u][k-1],st[v-(1<<k-1)+1][k-1]);
     86 }
     87 int main()
     88 {
     89     scanf("%d",&n);
     90     scanf("%s",str);
     91     for(int i=0;i<n;i++)
     92     {
     93         s[i]=str[i]-'a'+1;
     94     }
     95     s[n]=0;
     96     dc3(s,sa,n+1,30);
     97     calheight(s,sa,n);
     98     calmin(n);
     99     int t;
    100     for(int i=(n-1)/2;i>=0;i--)
    101     {
    102         f[i]=min(f[i+1]+2,n-2*i-1);
    103         if(!(f[i]&1))
    104             f[i]--;
    105         while(f[i]>0 && getmin(i,n-i-f[i])<f[i])
    106                 f[i]-=2;
    107     }
    108     for(int i=0;i<=(n-1)/2;i++)
    109         printf("%d ",f[i]);
    110     return 0;
    111 }
    View Code
  • 相关阅读:
    Chromium(Chrome) frame structure detail
    Chromium(Chrome) Sandbox Details
    ECMA6 New Features
    Asynchronous programming in javascript
    Restful OData Protocol
    java 历年版本特征(简化)
    λ 演算学习
    远程访问其他主机的Mysql(Ubuntu)
    NoSQL基础学习
    Apache solr 6.6.0安装
  • 原文地址:https://www.cnblogs.com/wujiechao/p/8720883.html
Copyright © 2011-2022 走看看