• HZNU Training 12 for Zhejiang Provincial Competition 2020


    A - Minimum’s Revenge

     HDU - 5922 

    签到;至于证明,当然是大胆假设。

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const ll mod=1e9+7;
    const int N=2e5+6;
    int main(){
        int t;
        scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);    
        int t,cas=0;
        scanf("%d",&t);
        while(t--){
            ll n;
        scanf("%lld",&n);
        ll ans=(n+1)*n/2-1;
        printf("Case #%d: %lld
    ",++cas,ans);
        }
        // system("pause");
        return 0;
    }
    View Code

    C - Mr. Frog’s Problem

     HDU - 5924 

    签到,怎么证明,不好讲,

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main(){
      int t;
      scanf("%d",&t);
      int cas=0;
      while(t--){
        printf("Case #%d:
    ",++cas);
        ll a,b,c,d;
        scanf("%lld %lld",&a,&b);
        if(a==b){
          puts("1");
          printf("%lld %lld
    ",a,b);
        }
        else {
          puts("2");
          printf("%lld %lld
    ",a,b);
          printf("%lld %lld
    ",b,a);
        }
      }
      return 0;
    }
    View Code

    D - Coconuts

     HDU - 5925 

    数据小的话,直接dfs解决,但1e9的数据量,需要离散化,

    把空行空列给压缩出来,压缩成一个全新的地图;

    然后dfs,蛋疼的bug,

    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #define pb(a) push_back(a)
    #define pii pair<int,int>
    using namespace std;
    typedef long long ll;
    const int d[4][2]= {0,1,1,0,0,-1,-1,0};
    int dir[][2]={{-1,0},{1,0},{0,-1},{0,1}};
    vector<ll> res;
    bool vis[402][402];
    ll v[402][402];
    int n,m,cntx,cnty;
    int xx[200],yy[200];
    ll sum;
    void dfs(int x,int y){
        if(vis[x][y])return;
        vis[x][y]=1;
        sum+=v[x][y];
        for(int k=0;k<4;k++){
          int dx=x+dir[k][0],dy=y+dir[k][1];
          if(vis[dx][dy])continue;
          if(dx<=0||dy<=0||dx>=cntx||dy>=cnty)continue;
          dfs(dx,dy);
        }
    }
    int main()
    {
        int t;
        scanf("%d",&t);
        for(int cas=1; cas<=t; cas++)
        {
            printf("Case #%d:
    ",cas);
            memset(vis,false,sizeof(vis));
            res.clear();
            vector<int> x,y;
            scanf("%d%d",&n,&m);
            x.pb(0);x.pb(n);y.pb(0);y.pb(m);
            int num;
            scanf("%d",&num);
            for(int i=0; i<num; i++)
            {
                scanf("%d%d",&xx[i],&yy[i]);
                x.pb(xx[i]-1),x.pb(xx[i]);
                y.pb(yy[i]-1),y.pb(yy[i]);
            }
            sort(x.begin(),x.end());
            sort(y.begin(),y.end());
            cntx=unique(x.begin(),x.end())-x.begin();
            cnty=unique(y.begin(),y.end())-y.begin();
            for(int i=1; i<cntx; i++)
                for(int j=1; j<cnty; j++)
                    v[i][j]=(ll)(x[i]-x[i-1])*(y[j]-y[j-1]);
            for(int i=0; i<num; i++)
            {
                int tx=lower_bound(x.begin(),x.begin()+cntx,xx[i])-x.begin();
                int ty=lower_bound(y.begin(),y.begin()+cnty,yy[i])-y.begin();
                vis[tx][ty]=true;
            
            }
            for(int i=1; i<cntx; i++)
                for(int j=1; j<cnty; j++)
                    if(!vis[i][j]){
                        sum=0;dfs(i,j);
                        res.pb(sum);
                    
                    }
            sort(res.begin(),res.end());
            int sz=res.size();
            printf("%d
    ",sz);
            for(int i=0;i<sz;i++)
                printf("%I64d%c",res[i],i==sz-1?'
    ':' ');
        }
    }
    View Code

    H - Basic Data Structure

     HDU - 5929 

    巨蛋疼的模拟,暴力无法解决,

    想的太多,做的太少;
  • 相关阅读:
    线上查询及帮助命令:
    windows: 2.7 3.5 (主要)
    get the execution time of a sql statement.
    java-kafka安装以及使用案例
    java-黑马头条 weex前端路由
    MYSQL安装
    缓存
    Flask中current_app和g对象
    [ValueError: signal only works in main thread]
    Flask-SQLAlchemy操作
  • 原文地址:https://www.cnblogs.com/littlerita/p/12554755.html
Copyright © 2020-2023  润新知