zoukankan      html  css  js  c++  java
  • ACM-ICPC 2015 ChangChun

    比赛链接 :点击这里

    大概会写 F G J L 吧

    F

    给你一个序列 最多删除一个数使他构成 最长不上升或者不下降子序列

    这题不会不会on的算法只能 t*n*logn 了 还是压常过 

    求两次 LIS 

    #include<bits/stdc++.h>
    using namespace std;
    #define maxn 300005
    #define ll int
    int a[maxn],b[maxn],c[maxn];
    int n;
    inline ll read()
    {
        ll 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 bin(int l,int r,int x){
       while(l<=r){
          int mid=(l+r)/2;
          if(b[mid]>=x){
             r=mid-1;
          }else l=mid+1;
       }
       return l;
    }
    int work(){
       memset(b,0,sizeof(b));
       int len=1;
       for(int j=0;j<n;j++){
          if(a[j]>=b[len-1]){
             b[len++]=a[j];
          }else{
            int i=bin(1,len,a[j]+1);
            b[i]=a[j];
          }
         // for(int j=1;j<=len;j++){
         //   cout<<b[j]<<" ";
         // }
          //cout<<endl;
       }
       return len-1;
    }
    int main(){
      int t;
      cin>>t;
      while(t--){
         n=read();
         int mi=1,mx=1;
         for(int j=0;j<n;j++){
           a[j]=read();
         }
         int len=work();
         reverse(a,a+n);
         int len1=work();
         if(len>=(n-1)||len1>=n-1){
            printf("YES
    ");
         }else printf("NO
    ");
      }
      return 0;
    }

    G 只有4个点才能组成一个正四边形

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    #include<queue>
    #include<stack>
    #include<math.h>
    #include<vector>
    #include<map>
    #include<set>
    #include<stdlib.h>
    #include<cmath>
    #include<string>
    #include<algorithm>
    #include<iostream>
    #define exp 1e-10
    using namespace std;
    const int N = 105;
    const int M = 2010;
    const int inf = 2147483647;
    const int mod = 2009;
    int x[N],y[N],L[6];
    int main()
    { 
        int  t,i,j,n,k; 
        scanf("%d",&t);
        while(t--)
        {
            scanf("%d",&n);
            for(i=0;i<n;i++)
                scanf("%d%d",&x[i],&y[i]);
            if(n!=4)
            {
                puts("NO");
                continue;
            }
            for(k=i=0;i<n;i++)
                for(j=0;j<i;j++,k++)
                    L[k]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
            sort(L,L+6);
            if(L[0]==L[1]&&L[2]==L[1]&&L[2]==L[3]&&L[4]==L[5]&&L[4]!=L[3])
                puts("YES");
            else
                puts("NO");
        }
        return 0; 
    }

    J

    字典树

    #include<bits/stdc++.h>
    using namespace std;
    #define maxn 1000100
    #define LL long long
    LL a[maxn];
    struct ac{
       LL x,nex[3];
       void init(){
         x=0;
         memset(nex,0,sizeof(nex));
       }
    }tre[maxn];
    LL tot,n;
    void init(){
       memset(tre,0,sizeof(tre));
       tot=0;
    }
    void add(LL x){
       LL k=0;
       tre[k].x++;
       for(LL j=30;j>=0;j--){
          bool fa=((1LL*(1<<j))&x);
          if(tre[k].nex[fa]==0){
             tre[k].nex[fa]=++tot;
             tre[tot].init();
          }
          k=tre[k].nex[fa];
          tre[k].x++;
       }
    }
    void del(LL x){
       LL k=0;
       tre[k].x--;
       for(LL j=30;j>=0;j--){
          bool fa=((1LL*(1<<j))&x);
          k=tre[k].nex[fa];
          tre[k].x--;
       }
    }
    LL query(LL x){
      LL k=0,ans=0;
      for(LL j=30;j>=0;j--){
         bool fa=((1LL*(1<<j))&x);
         if(tre[k].nex[fa^1]&&tre[tre[k].nex[fa^1]].x>0){
            ans+=1LL*(1<<j);
            k=tre[k].nex[fa^1];
         }else k=tre[k].nex[fa];
      }
      return ans;
    }
    int main(){
       LL t;
       cin>>t;
       while(t--){
          cin>>n;
          init();
          for(LL j=0;j<n;j++){
             scanf("%d",&a[j]);
             add(a[j]);
          }
          LL mx=0;
          for(int j=0;j<n;j++){
             for(int k=j+1;k<n;k++){
                del(a[j]);
                del(a[k]);
                mx=max(mx,query(a[j]+a[k]));
                add(a[j]);
                add(a[k]);
             }
          }
          cout<<mx<<endl;
       }
    }

    L

    Select Code
    #include<bits/stdc++.h>
    using namespace std;
    #define maxn 100
    int a[maxn][maxn];
    int main(){
       int t;
       cin>>t;
       while(t--){
          int n,m,mx=0,ans=0;
          cin>>n>>m;
          for(int j=1;j<=n;j++){
             for(int k=1;k<=m;k++){
                cin>>a[j][k];
                mx=max(mx,a[j][k]);
                if(a[j][k]){
                   ans+=a[j][k]*4+1;
                }
             }
          }
          for(int j=1;j<=n;j++){
             for(int k=1;k<=m;k++){
                int z=min(a[j-1][k],a[j][k]);
                int zz=min(a[j][k-1],a[j][k]);
                ans-=z*2;
                ans-=zz*2;
             }
          }
          cout<<ans<<endl;
       }
       return 0;
    }
  • 相关阅读:
    python--模块与包
    内置函数 的总结
    迭代器 生成器 列表推导式 生成器表达式的一些总结
    函数的有用信息 带参数的装饰器 多个装饰器装饰一个函数
    函数名的应用(第一对象) 闭包 装饰器
    动态参数 名称空间 作用域 作用域链 加载顺序 函数的嵌套 global nonlocal 等的用法总结
    函数的初识 函数的返回值 参数
    文件操作 常用操作方法 文件的修改
    遍历字典的集中方法 集合的作用 以及增删查的方法
    计算机硬件的小知识
  • 原文地址:https://www.cnblogs.com/Dvelpro/p/9925082.html
Copyright © 2011-2022 走看看