• 第十七周 12.20-12.26


    12.20-12.22

    什么都没做。

    12.23

    POJ 3581 Sequence

    这是一个单case过EOF哇的神题。我只是想验个板阿QAQ。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <algorithm>
     5 using namespace std;
     6 const int maxn = 1e6 + 10;
     7 
     8 int s[maxn], rev[maxn];
     9 int n, k, SA[maxn], r[maxn], tmp[maxn];
    10 bool cmp(int i, int j)
    11 {
    12     if(r[i] != r[j]) return r[i] < r[j];
    13     return ( i + k <= n ? r[i+k] : -1 ) < ( j + k <= n ? r[j+k] : -1 );
    14 }
    15 void get_SA(int sz)
    16 {
    17     for(int i = 0; i <= sz; i++)
    18     {
    19         SA[i] = i;
    20         r[i] = i < sz ? rev[i] : -1;
    21     }
    22     for(k = 1; k <= sz; k <<= 1)
    23     {
    24         sort(SA, SA + sz + 1, cmp);
    25         tmp[SA[0]] = 0;
    26         for(int i = 1; i <= sz; i++) tmp[SA[i]] = tmp[SA[i-1]] + cmp(SA[i-1], SA[i]);
    27         memcpy(r, tmp, sizeof(r));
    28     }
    29     return;
    30 }
    31 
    32 void R(int * t, int l, int r)
    33 {
    34     for(int i = 0; i <= (r - l) / 2; i++) swap(t[l+i], t[r-i]);
    35 }
    36 
    37 int main(void)
    38 {
    39     scanf("%d", &n);
    40     int p1, p2;
    41     for(int i = 0; i < n; i++) scanf("%d", s + i);
    42     memcpy(rev, s, sizeof(rev));
    43     R(rev, 0, n - 1);
    44     get_SA(n);
    45     for(int i = 0; i <= n; i++)
    46         if(SA[i] > 1 && SA[i] < n)
    47             {p1 = n - SA[i]; break;}
    48     int m = n - p1;
    49     for(int i = 0; i < m; i++) rev[i] = rev[i + m] = s[p1 + i];
    50     R(rev, 0, 2 * m - 1);
    51     get_SA(2 * m);
    52     for(int i = 0; i <= 2 * m; i++)
    53     {
    54         p2 = p1 + m - SA[i];
    55         if(p2 > p1 && p2 < n) break;
    56     }
    57     R(s, 0, p1 - 1);
    58     R(s, p1, p2 - 1);
    59     R(s, p2, n - 1);
    60     for(int i = 0; i < n; i++) printf("%d
    ", s[i]);
    61     return 0;
    62 }
    Aguin

    12.24

    补个CF。

    CF 608 C Chain Reaction

    dp推。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 using namespace std;
     5 const int maxn = 1e6 + 10;
     6 int pos[maxn], level[maxn];
     7 int dp[maxn];
     8 
     9 int main(void)
    10 {
    11     int n;
    12     scanf("%d", &n);
    13     for(int i = 1; i <= n; i++)
    14     {
    15         int a, b;
    16         scanf("%d%d", &a, &b);
    17         pos[a] = 1;
    18         level[a] = b;
    19     }
    20     int ans = 0;
    21     for(int i = 0; i < maxn; i++)
    22     {
    23         if(!pos[i]) dp[i+1] = dp[i];
    24         else dp[i+1] = (i - level[i] >= 0 ? dp[i-level[i]] : 0 ) + 1;
    25         ans = max(ans, dp[i+1]);
    26     }
    27     printf("%d
    ",n - ans);
    28     return 0;
    29 }
    Aguin

    CF 608 D Zuma

    不会捉。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 using namespace std;
     5 int c[555], dp[555][555];
     6 
     7 int main(void)
     8 {
     9     int n;
    10     scanf("%d", &n);
    11     for(int i = 1; i <= n; i++) scanf("%d", c + i);
    12     for(int i = 1; i <= n; i++)
    13         for(int j = i; j <= n; j++)
    14             dp[i][j] = (i == j ? 1 : n + 1 );
    15     for(int l = 2; l <= n; l++)
    16     {
    17         for(int s = 1; s + l - 1 <= n; s++)
    18         {
    19             for(int k = s; k < s + l - 1; k++)
    20                 dp[s][s+l-1] = min(dp[s][s+l-1], dp[s][k] + dp[k+1][s+l-1]);
    21             if(c[s] == c[s+l-1]) dp[s][s+l-1] = max(1, min(dp[s][s+l-1],dp[s+1][s+l-2]));
    22         }
    23     }
    24     printf("%d
    ", dp[1][n]);
    25     return 0;
    26 }
    Aguin

    CF 608 E Marbles

    不懂证。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 using namespace std;
     5 const int maxn = 1e6 + 10;
     6 int n, Next[maxn];
     7 char a[maxn], b[maxn];
     8 
     9 void getNext(void)
    10 {
    11     Next[0] = Next[1] = 0;
    12     for(int i = 1; i < n; i++)
    13     {
    14         int j = Next[i];
    15         while( j && b[i] != b[j]) j = Next[j];
    16         Next[i+1] = b[i] == b[j] ? j + 1 : 0;
    17     }
    18     return;
    19 }
    20 
    21 bool KMP(void)
    22 {
    23     getNext();
    24     int j = 0;
    25     for(int i = 0; i < n; i++)
    26     {
    27         while(j && b[j] != a[i]) j = Next[j];
    28         if(b[j] == a[i]) j++;
    29         if(i == n - 1 && j) return true;
    30     }
    31     return false;
    32 }
    33 
    34 int main(void)
    35 {
    36     scanf("%d", &n);
    37     n--;
    38     scanf("%s%s", a, b);
    39     for(int i = 0; i < n; i++)
    40     {
    41         if(b[i] == 'N') b[i] = 'S';
    42         else if(b[i] == 'S') b[i] = 'N';
    43         else if(b[i] == 'E') b[i] = 'W';
    44         else b[i] = 'E';
    45     }
    46     reverse(b, b + n);
    47     puts(KMP() ? "NO" : "YES");
    48     return 0;
    49 }
    Aguin

    12.25-12.26

    什么都没干。

  • 相关阅读:
    【sqli-labs】 less23 Error based
    【sqli-labs】 less22 Cookie Injection- Error Based- Double Quotes
    【sqli-labs】 less21 Cookie Injection- Error Based- complex
    【sqli-labs】 less20 POST
    【sqli-labs】 less19 POST
    【sqli-labs】 less18 POST
    【sqli-labs】 less17 POST
    【sqli-labs】 less16 POST
    【sqli-labs】 less15 POST
    nginx.conf(centos7 1.14)主配置文件修改
  • 原文地址:https://www.cnblogs.com/Aguin/p/5065101.html
Copyright © 2020-2023  润新知