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. java爬虫系列第三讲-获取页面中绝对路径的各种方法

    在使用webmgiac的过程中,很多时候我们需要抓取连接的绝对路径,总结了几种方法,示例代码放在最后. 以和讯网的一个页面为例: xpath方式获取 log.info("{}", ...

  2. Ext.isNumber与Ext.isNumeric

    Ext.isNumber: Ext.isNumber(1) true Ext.isNumber(new Number(1)) false Ext.isNumber("1") fal ...

  3. OPP的三大特征之封装总结

    '''封装: 1.什么是封装? 封装是把什么东西装到容器中,再封闭起来 与隐藏有相似之处,但不是单纯的隐藏 官方解释:封装是指对外部隐藏实现细节,并提供简单的使用接口 封装的好处: 1.提高安全性 2 ...

  4. JS添加或删除HTML dom元素的方法实例分析

    本文实例讲述了JS代码添加或删除HTML dom元素的方法.分享给大家供大家参考,具体如下: 创建新的 HTML 元素 如需向 HTML DOM 添加新元素,您必须首先创建该元素(元素节点),然后向一 ...

  5. 判断点在多边形内算法的C++实现

    目录 1. 算法思路 2. 具体实现 3. 改进空间 1. 算法思路 判断平面内点是否在多边形内有多种算法,其中射线法是其中比较好理解的一种,而且能够支持凹多边形的情况.该算法的思路很简单,就是从目标 ...

  6. ArcGIS API for JavaScript 与 npm 之例子运行

    下载官方的demo,4.7的,在终端里跑了一下,测试成功(未打包) 在测试中精简掉了不需要的文件,使用http协议跑的(file协议不行哦) 最简单的目录如下: 我把以上文件放到一个叫demo的文件夹 ...

  7. Jmeter、Java当double显示的数字过长时取消科学计数法显示

    今日,由于项目需要,使用Jmeter发送查询账户并不保存余额,经过交易后,进行运算后再次比对余额. 实施过程中获取了余额字段并赋值给一个double变量.变量进行运算后再与交易后的账户余额进行比对.这 ...

  8. Java通过JDBC连接数据库的三种方式!!!并对数据库实现增删改查

    前言 java连接数据库完整流程为: 1,获得驱动(driver),数据库连接(url),用户名(username),密码(password)基本信息的三种方式. 2,通过获得的信息完成JDBC实现连 ...

  9. zabbix调用api检索方法

    环境 zabbix:172.16.128.16:zabbix_web:172.16.16.16/zabbix 用户名:Admin 密码:zabbix 获取的数据仅做参考,以Linux发送HTTP的PO ...

  10. RabbitMQ框架构建系列(二)——RabbitMQ基础知识介绍

    上一篇记录了一下AMQP协议,RabbitMQ是一个Erlang开发的AMQP协议的开源实现.这一篇简单的介绍一下RabbitMQ的基本原理. 一.RabbitMQ的特点 1.可靠性:RabbitMQ ...