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. mybatis 参数格式异常-- Error querying database. Cause: java.lang.NumberFormatException: For input string

    mybatis中 <if></if>标签中进行判断时,如果传入的时字符格式和数字进行判断需要将数字进行转译,否则默认是数字和数字进行比较,这是就会出现参数格式异常如<if ...

  2. nginx 启动错误

    场景 在Windows下 启动nginx报错: nginx: [error] ReadFile() : Incorrect function) 解决 因为 nginx.conf 中存在 /* 被认为是 ...

  3. python之循环(增删)内使用list.remove()

    dat=['] for item in dat: ': dat.remove(item) print(dat) #按要求是把'0'都删掉的,输出结果是['1', '2', '3', '0'] ?? 首 ...

  4. HTML页面转换为Sharepoint母版页(实战)

    分享人:广州华软 极简 一. 前言 SharePoint有母版页.布局页.母版页存放着如头部(顶部菜单.导航),底部等比较通用部分,通常网站只需一套即可:而布局页,则存放着主要内容部分,根据页面需要, ...

  5. 生鲜配送管理系统_升鲜宝供应链系统V2.0 设计思想及主要模块,欢迎大家批评指点。

    前言: 经过这几年的开发,升鲜宝生鲜供应链系统管理软件,终于完成C/S与B/S二个版本的开发,先主要介绍B/S版本的功能,C/S版本的功能更加完善. 升鲜宝供应链系统主要由以下几个主要端组成:     ...

  6. Android项目实战(四十五):Zxing二维码切换横屏扫描

    Demo链接 默认是竖屏扫描,但是当我们在清单文件中配置横屏显示的时候: <activity android:name=".CaptureActivity" android: ...

  7. 记一次使用SimpleDateFormat 格式化时间时遇到的问题

    网上的使用方法一大堆,我就不再介绍了,就写一下自己遇到的问题. 先来实现一下获取当前时间: SimpleDateFormat simpleDateFormat =new SimpleDateForma ...

  8. 经度和纬度在SQL中的数据类型

    冬天太冷,等坐公司班车也很冷,就萌生了给班车做一个到站查询功能. 在某宝上买了汽车在线的GPS设备, 终生免费的服务的. 这里不得不提下这个设备的优点, 它提供API接口,还是免费的. 所以在班车上装 ...

  9. anaconda的scikit-learn报错It seems that scikit-learn has not been built

    我们在导入sklearn时往往会报错. import sklearn Traceback (most recent call last): File "<stdin>" ...

  10. wireshark抓包,安装及简单使用

    跟着实验室师兄尝试做流量分析,趁着离期末考试还有几天,尽快把环境搭好. 采集:自动化测试monkeyrunner,ok 抓包 charles/Wireshark,ok 限制其他应用运行App Moun ...