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. Spring Boot Security 整合 OAuth2 设计安全API接口服务

    简介 OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到广泛应用,目前的版本是2.0版.本文重点讲解Spring Boot项目对OAuth2进行的实现,如果你对OAut ...

  2. Program Thread 和 Process的不同点

    Thread is for execution Kernel level thread, physical parallelism Cores Divide work amount of physic ...

  3. git 取消对某个文件的跟踪

    git rm --cached <fileName> 例如 : git add 后,不想提交在status里的.idea/vcs.xml.操作如下:

  4. 第三次上机,ADO接口的使用

    <html> <head> <title>Reg</title> </head> <body><center> &l ...

  5. (五)图数据库数neo4j据备份与恢复

    1.备份方式 neo4j目前有三种备份方式: (1)java在线备份,通过java程序可在neo4j启动状态下备份数据,也可远程备份(社区版本目前不支持) (2)neo4j-admin工具,可在neo ...

  6. 将CSV文件写入MySQL

    先打开CSV文件查看第一行有哪些字段,然后新建数据库,新建表.(若字段内容很多建议类型text,如果设成char后续会报错) 命令如下: load data infile '路径XXXX.csv' i ...

  7. 从0开始的Python学习012数据结构&对象与类

    简介 数据结构是处理数据的结构,或者说,他们是用来存储一组相关数据的. 在Python中三种内建的数据结构--列表.元组和字典.学会了使用它们会使编程变得的简单. 列表 list是处理一组有序的数据结 ...

  8. Python之python的一些理解

    应用领域: 1. 网络爬虫 2. 大数据分析与挖掘 3. 机器学习 4. web应用 5. 游戏开发 6. 自动化运维 入门学习网站: imooc,廖雪峰,黑马 环境变量 --- 就是告诉电脑,你的程 ...

  9. cent os 7 与cent os 6区别

    原文地址:https://www.cnblogs.com/Csir/p/6746667.html 前言 centos7与6之间最大的差别就是初始化技术的不同,7采用的初始化技术是Systemd,并行的 ...

  10. 记录Javascript的数据方法参考

    concat >>连接2个或更多数组,并返回结果 var arr1 = [1,2,3]; var arr2 = [-1,-2,-3]; console.log(arr1.concat(ar ...