POJ2926

先学会这个哈夫曼距离的处理才能做 cf 的G

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
#define maxn 100005
const int inf = (int)1e9;
];
<<+],mx[<<+];
int main(){
   int n;
   scanf("%d",&n);
   ;j<n;j++){
      ;k<;k++){
         scanf("%lf",&a[j][k]);
      }
   }
   ;j<(<<);j++){
      mi[j] = inf;
      mx[j] = -inf;
   }
  // double mx = 0,mi = inf;
   double ans = -inf;
   ;j<n;j++){
      //int cur = 0.
      ;k<(<<);k++){
         ;
         ;i<;i++){
            <<i)){
               cur += a[j][i];
            }else{
               cur -= a[j][i];
            }
         }
         //cout<<cur<<endl;
         mx[k] = max(mx[k],cur);
         mi[k] = min(mi[k],cur);
         //ans = max(ans,mx[j]-mi[j]);
      }
   }
   ;j<(<<);j++){
      //cout<<mx[j]<<" "<<mi[j]<<endl;
      ans = max(ans,mx[j]-mi[j]);
   }
   printf("%0.2f\n",ans);

}

点一下    题目链接

CF G 用线段树处理一下

就ok

#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
#define inf (int)1e9
*maxn][];
*maxn][];
int n,m;
void build(int l,int r,int in){
  if(l==r){
     ;j<(<<m);j++){
        ;
        ;k<m;k++){
           <<k)){
              cur+=b[l][k];
           }else cur-=b[l][k];
        }
        //cout<<cur<<endl;
        a[in][j] = cur;
     }
     return ;
  }
  ;
  build(l,mid,);
  build(mid+,r,+);
  ;j<(<<m);j++){
     a[][j],a[+][j]);
  }
}
void up(int l,int r,int x,int in){
    if(l==r){
        ;j<(<<m);j++){
          ;
          ;k<m;k++){
             <<k)){
                cur+=b[l][k];
             }else cur-=b[l][k];
          }
          a[in][j] = cur;
        }
        return ;
    }
    ;
    if(x>mid){
       up(mid+,r,x,+);
    }else{
       up(l,mid,x,);
    }
    ;j<(<<m);j++){
      a[][j],a[+][j]);
    }
}
int query(int l,int r,int x,int y,int i,int in){
    //if(x>y) return inf;
    if(l==x&&r==y){
       return a[in][i];
    }
     ;
     if(x>mid){
        ,r,x,y,i,+);
     }else if(y<=mid){
        );
     }
     ),query(mid+,r,mid+,y,i,+));
}
int main(){
   cin>>n>>m;
   ;j<=n;j++){
      ;k<m;k++){
         scanf("%d",&b[j][k]);
      }
   }
   build(,n,);
//   for(int j=0;j<(1<<m);j++){
//     cout<<a[1][j]<<endl;
//   }
   int t; cin>>t;
   while(t--){
      int z;
      scanf("%d",&z);
      ){
         int i;
         scanf("%d",&i);
         ;j<m;j++){
            scanf("%d",&b[i][j]);
         }
         up(,n,i,);
      }else{
         ;
         scanf("%d%d",&l,&r);
         ;j<(<<(m-));j++){
             ,n,l,r,j,);
             ,n,l,r,j^((<<m)-),);
             //cout<<x<<" "<<y<<endl;
             mx = max(mx,abs(x+y));
         }
         printf("%d\n",mx);
      }
   }
   ;
}

POJ-2926-Requirements&&Educational Codeforces Round 56G. Multidimensional Queries 【哈夫曼距离】的更多相关文章

  1. Educational Codeforces Round 2 B. Queries about less or equal elements 水题

    B. Queries about less or equal elements Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforc ...

  2. Educational Codeforces Round 1 B. Queries on a String 暴力

    B. Queries on a String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/59 ...

  3. Educational Codeforces Round 2 B. Queries about less or equal elements

    打开题目连接 题意:给2个数组(无序的)啊a,b,判断b数组中的每一个元素大于a数组中个数. ACcode: #include <iostream> #include <vector ...

  4. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  5. [Educational Codeforces Round 16]D. Two Arithmetic Progressions

    [Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...

  6. [Educational Codeforces Round 16]C. Magic Odd Square

    [Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...

  7. [Educational Codeforces Round 16]B. Optimal Point on a Line

    [Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...

  8. [Educational Codeforces Round 16]A. King Moves

    [Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...

  9. Educational Codeforces Round 6 C. Pearls in a Row

    Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...

随机推荐

  1. I/O输入流基础之FileInputStream

    InputStream:是所有字节输入流的父类,其作用是:用这个流把网络数据(getOutputStream()),文件系统的数据读入内存 由与  public abstract class Inpu ...

  2. MySQL分组查询与连接查询

    一,分组查询 使用ORDER BY子句将表中的数据分成若干组(还是按行显示) 语法: SELECT 字段名[,聚集函数] FROM 表名 [WHERE子句] GROUP BY 要分组的字段名 [ORD ...

  3. 关于boostrap的modal隐藏问题(前端框架)

    Modal(模态框) 首先,外引boostrap和Jquery的文件环境: <link rel="stylesheet" href="https://cdn.sta ...

  4. vue的表单编辑删除,保存取消功能

    过年回来第一篇博客,可能说的不是很清楚,而且心情可能也不是特别的high,虽然今天是元宵,我还在办公室11.30在加班,但就是想把写过的代码记下来,怕以后可能真的忘了.(心将塞未塞,欲塞未满) VUE ...

  5. 转:Git Submodule管理项目子模块

    使用场景 当项目越来越庞大之后,不可避免的要拆分成多个子模块,我们希望各个子模块有独立的版本管理,并且由专门的人去维护,这时候我们就要用到git的submodule功能. 常用命令 git clone ...

  6. go的生产者-消费者模式

    package main import ( "fmt" "math/rand" "time" ) // 数据生产者 func produce ...

  7. Java基础之入门

    写写基础,顺便回顾下,再深层次思考下哪些深入的没弄明白. Java是Sun Microsystems于1995年推出的高级编程语言  其版本 由 1.1 -> 1.2 -> 1.3 -&g ...

  8. Jenkins 配置 Git 错误解决:CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt

    错误信息: Failed to connect to repository : Command "C:/tools/Git/bin/git.exe ls-remote -h https:/X ...

  9. 码农也来关注下经济问题<美元加息>对我们的影响

    昨天凌晨三点,美联储宣布加息25个基点,这是今年美联储第四次加息,也是2015年12月份以来的第九次加息.基准利率又上调了25个基点,全球市场又要开始惴惴不安了. 要知道上一次美国基准利率上调25个基 ...

  10. 《Python神经网络编程》的读书笔记

    文章提纲 全书总评 读书笔记 C01.神经网络如何工作? C02.使用Python进行DIY C03.开拓思维 附录A.微积分简介 附录B.树莓派 全书总评 书本印刷质量:4星.纸张是米黄色,可以保护 ...