5085:最大

  • 给你一个n×m的矩形,要你找一个子矩形,价值为左上角左下角右上角右下角这四个数的最小值,要你最大化矩形
    的价值。
  • 关键点是要想到把这些值排序
  • 值从小到大考虑,比如说现在最小的值是(x1,yi)那一个,那我肯定不能选择它,因为我另外选四个一定得到更优解
  • 所以值从小到大考虑的话,当前如果我不是没得选了,我都不会去选那些小值。
  • 那假如小值是黑点,大值是白点,什么时候选四个白点作为一个矩形只有一种方案呢?
  • 画一下就大概知道此时白点的数目不会超过 2*(n+m)
  • 所以从大到小考虑值暴力看可不可以构成矩形就星了。
  • ------在别的大佬博客上看到的做法:https://www.cnblogs.com/CQzhangyu/p/7886896.html
  • 这个做法在不知道答案是在2*(n+m)以内的情况下复杂度就是n方了,orzorz
  • 代码:
     #include <cstdio>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #define nmax 1000010 using namespace std;
    typedef long long ll;
    int n,m,idx=-;
    struct mat{
    int v,x,y;
    bool operator < (const mat tcmp) const {
    return tcmp.v<v;
    }
    }ma[nmax];
    vector <int> x[];
    int map[][]={}; int main(){
    cin>>n>>m;
    for (int i=; i<n; i++) for (int j=; j<m; j++) {
    scanf("%d",&ma[++idx].v);
    ma[idx].x=i;
    ma[idx].y=j;
    }
    sort(ma,ma+idx+);
    for (int i=; i<=idx; i++) {
    int tx = ma[i].x;
    for (int j=; j<x[tx].size(); j++) {
    int ty = x[tx][j];
    if( map[ty][ ma[i].y ] ){
    cout << ma[i].v << endl;
    return ;
    }
    map[ty][ ma[i].y ] = ;
    map[ ma[i].y ][ty] = ;
    }
    x[ ma[i].x ].push_back( ma[i].y );
    }
    return ;
    }

    (ಥ _ ಥ)

2456: mode

  • 给你一个n个数的数列,其中某个数出现了超过n div 2次即众数,请你找出那个数。(只能开几个变量)
  • 只能说妙啊,果然bzoj无水题,刷个水题列表都如此艰难的蒟蒻枯了。
  • 大概就是用后面的和它不一样的数数抵消前面的数,众数是不会被抵消完的。。康康代码就okk拉
  • 代码:
     #include <cstdio>
    
     typedef long long ll;
    
     int main(){
    int n;
    ll in,now,cnt=;
    scanf("%d",&n);
    scanf("%lld",&in);
    now=in;
    for (int i=; i<n; i++) {
    scanf("%lld",&in);
    if(in==now) cnt++; else cnt--;
    if(cnt<) { now=in; cnt=; }
    }
    printf("%lld\n",now);
    return ;
    }

    d=====( ̄▽ ̄*)b

BZOJ的思维题的更多相关文章

  1. HDU 1029 Ignatius and the Princess IV / HYSBZ(BZOJ) 2456 mode(思维题,~~排序?~~)

    HDU 1029 Ignatius and the Princess IV (思维题,排序?) Description "OK, you are not too bad, em... But ...

  2. BZOJ 2734 洛谷 3226 [HNOI2012]集合选数【状压DP】【思维题】

    [题解] 思维题,看了别人的博客才会写. 写出这样的矩阵: 1,3,9,... 2,6,18,... 4,12.36,... 8,24,72,... 我们要做的就是从矩阵中选出一些数字,但是不能选相邻 ...

  3. zoj 3778 Talented Chef(思维题)

    题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...

  4. cf A. Inna and Pink Pony(思维题)

    题目:http://codeforces.com/contest/374/problem/A 题意:求到达边界的最小步数.. 刚开始以为是 bfs,不过数据10^6太大了,肯定不是... 一个思维题, ...

  5. ZOJ 3829 贪心 思维题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商 ...

  6. 洛谷P4643 [国家集训队]阿狸和桃子的游戏(思维题+贪心)

    思维题,好题 把每条边的边权平分到这条边的两个顶点上,之后就是个sb贪心了 正确性证明: 如果一条边的两个顶点被一个人选了,一整条边的贡献就凑齐了 如果分别被两个人选了,一作差就抵消了,相当于谁都没有 ...

  7. C. Nice Garland Codeforces Round #535 (Div. 3) 思维题

    C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  8. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  9. UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There Was One / POJ 3517 And Then There Was One / Aizu 1275 And Then There Was One (动态规划,思维题)

    UVA 1394 And Then There Was One / Gym 101415A And Then There Was One / UVAlive 3882 And Then There W ...

随机推荐

  1. toj 3019 Hidden Password (最小表示法)

    Hidden Password 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交: 53 测试通过: 19 描述 Some time the progr ...

  2. Valiant Hearts: The Great War -- 《勇敢的心》

    “友情,爱情,亲情”

  3. linux--解决celery消息中间件带来的一系列问题

    启动celery定时任务 1.celery -A OpsManage beat -l info -S django 2.celery -A OpsManage worker -l info 此时消息中 ...

  4. 关系模式范式分解教程 3NF与BCNF口诀

    https://blog.csdn.net/sumaliqinghua/article/details/86246762 [通俗易懂]关系模式范式分解教程 3NF与BCNF口诀!小白也能看懂原创置顶 ...

  5. 这个 Python 代码自动补全神器搞得我卧槽卧槽的

    是时候跟你说说这个能让你撸代码撸得舒服得不要不要的神器了——kite. ​!   ​ 简单来说,它是一款 IDE 的插件,能做到代码自动补全,可能你会说了,这有什么牛逼的?一般的编辑器不都有这个功能么 ...

  6. Git命令行操作方法

    1.GitHub上创建一个Repositories(仓库),并复制仓库地址

  7. 关于hp proliant sl210t服务器raid 1阵列配置(HP P420/Smart Array P420阵列卡配置)

    hp proliant sl210t服务器,一般都会带有两个阵列卡 一个服务器自带的Dynamic Smart Array B120i RAID控制器,一个为Slot卡槽上的Smart Array P ...

  8. cra

    const paths = require('react-scripts/config/paths'); paths.appBuild = path.join(path.dirname(paths.a ...

  9. UVA-1588

    只用C来写 题目:https://vjudge.net/problem/UVA-1588 #include<stdio.h> #include<string.h> #defin ...

  10. python3.6安装PyUserInput

    python3.6安装PyUserInput https://www.cnblogs.com/yoyoketang/p/8043814.html