• cf 766#


    天呢,太垃圾了我。。

    AB懵逼了半天题意,C最后搞了个DP还不对。。。DP太垃圾了,,

     1 #include<bits/stdc++.h>
     2 #define INF 0x7fffffff
     3 #define LL long long
     4 #define N 100005
     5 using namespace std;
     6 inline int ra()
     7 {
     8     int x=0,f=1; char ch=getchar();
     9     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    10     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    11     return x*f;
    12 }
    13 int main()
    14 {
    15     string s1,s2; cin>>s1>>s2;
    16     if (s1.length()!=s2.length())
    17     {
    18         if (s1.length()>s2.length())
    19             cout<<s1.length();
    20         else cout<<s2.length();
    21     }
    22     else 
    23     {
    24         if (s1==s2) cout<<"-1";
    25         else cout<<s1.length();
    26     }
    27     return 0;
    28 }
    #include<bits/stdc++.h>
    #define INF 0x7fffffff
    #define LL long long
    #define N 100005
    using namespace std;
    inline int ra()
    {
        int x=0,f=1; char ch=getchar();
        while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
        while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
        return x*f;
    }
    int a[N];
    int main()
    {
        int n=ra();
        for (int i=1; i<=n; i++) a[i]=ra();
        sort(a+1,a+n+1);
        for (int i=1; i<=n-2; i++)
        {
            if (a[i]+a[i+1]>a[i+2] && a[i+1]-a[i]<a[i+2])
            {
                cout<<"YES";
                return 0;
            }
        }
        cout<<"NO";
        return 0;
    }
      1 /*#include<bits/stdc++.h>
      2 #define INF 0x7fffffff
      3 #define LL long long
      4 #define N 100005
      5 using namespace std;
      6 inline LL ra()
      7 {
      8     LL x=0,f=1; char ch=getchar();
      9     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
     10     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
     11     return x*f;
     12 }
     13 bool vis[1005][1005];
     14 LL n,f[1005][1005],a[50],anslen;
     15 char s[1005];
     16 const LL mod=1e9+7;
     17 int main()
     18 {
     19     n=ra(); scanf("%s",s+1);
     20     for (LL i=0; i<26; i++) a[i]=ra();
     21     LL mn=INF;
     22     for (LL i=1; i<=n; i++)
     23     {
     24         mn=min(mn,a[s[i]-'a']);
     25         if (mn<i) break;
     26         f[i][1]=1;
     27         vis[i][1]=1;
     28         anslen=max(anslen,i);
     29     }
     30     for (LL i=1; i<=n; i++)
     31     {
     32         for (LL j=2; j<=i; j++)
     33         {
     34             LL mn=a[s[i]-'a'],cnt=1;
     35             for (LL k=i-1; k>=1; k--,cnt++)
     36             {
     37                 mn=min(mn,a[s[k]-'a']);
     38                 if (mn<cnt) break;
     39                 f[i][j]+=f[k][j-1];
     40                 if (vis[k][j-1]) vis[i][j]=1;
     41                 f[i][j]%=mod;
     42                 if (vis[k][j-1]) anslen=max(anslen,cnt);
     43             }
     44         }
     45     }
     46     LL anstot=0,ansnum;
     47     for (LL i=1; i<=n; i++) anstot+=f[n][i],anstot%=mod;
     48     cout<<anstot<<endl;
     49     for (LL i=1; i<=n; i++) 
     50         if (f[n][i]) 
     51         {
     52             ansnum=i;
     53             break;
     54         }
     55     cout<<anslen<<endl<<ansnum;
     56     return 0;
     57 }*/
     58 #include<bits/stdc++.h>
     59 #define INF 0x7fffffff
     60 #define LL long long
     61 #define N 100005
     62 using namespace std;
     63 inline LL ra()
     64 {
     65     LL x=0,f=1; char ch=getchar();
     66     while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
     67     while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
     68     return x*f;
     69 }
     70 int f[N],n,dp[N],a[N],mx;
     71 char s[N];
     72 const int mod=1e9+7;
     73 bool check(int i, int j)
     74 {
     75     int l=j-i+1;
     76     for (int k=i; k<=j; k++)
     77     {
     78         if (a[s[k]-'a']<l)
     79             return 0;
     80     }
     81     return 1;
     82 }
     83 int main()
     84 {
     85     n=ra(); scanf("%s",s+1);
     86     for (int i=0; i<26; i++) a[i]=ra();
     87     memset(f,0x3f,sizeof(f));
     88     dp[0]=1; f[0]=0;
     89     for (int i=1; i<=n; i++)
     90         for (int j=1; j<=i; j++)
     91             if (check(i-j+1,i))
     92             {
     93                 dp[i]=(dp[i]+dp[i-j])%mod;
     94                 f[i]=min(f[i],f[i-j]+1);
     95                 if (dp[i-1]) mx=max(mx,j);
     96             }
     97     cout<<dp[n]<<endl;
     98     cout<<mx<<endl;
     99     cout<<f[n]<<endl;
    100 }
  • 相关阅读:
    QT *.pri 语法学习
    qt 的相对路径说法
    openwrt 时间更新
    openwrt network 初始化
    在线配置热加载配置 go-kratos.dev 监听key 通过atomic.Value支持自动热加载
    Monkey patching
    UDP flood UDP Port Denial-of-Service Attack
    一例 Go 编译器代码优化 bug 定位和修复解析
    t
    golang 网络编程之如何正确关闭tcp连接以及管理它的生命周期 socket
  • 原文地址:https://www.cnblogs.com/ccd2333/p/6385126.html
Copyright © 2020-2023  润新知