\(des\)

存在 \(1000 \times 1000\) 的矩阵,保证元素互不相同,\(2e5\) 次询问,每次询

问给定 \(x, y\) 问存在多少点 \((a, b)\) 满足该元素是 \(a\) 行的 \(x\) 大, \(b\)

列的 \(y\) 大。

\(sol\)

这数据范围给的不敢写暴力啊,然而这 T1 就是暴力啊

需要对所有可能的情况预处理,处理处所有可能的询问

时间复杂度 \(O(n^2logn)\)

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string> using namespace std;
const int N = 1010; #define gc getchar()
#define Rep(i, a, b) for(int i = a; i <= b; i ++)
#define LL long long inline int read() {int x = 0; char c = gc; while(c < '0' || c > '9') c = gc;
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = gc; return x;}
inline LL readLL() {LL x = 0; char c = gc; while(c < '0' || c > '9') c = gc;
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = gc; return x;} int A[N][N], B[N][N];
int Sa[N][N], Sb[N][N];
int Answer[N][N];
int n, m, q; int main() {
n = read(), m = read(), q = read();
Rep(i, 1, n) Rep(j, 1, m) A[i][j] = read();
Rep(i, 1, m) Rep(j, 1, n) B[i][j] = A[j][i];
Rep(i, 1, n) Rep(j, 1, m) Sa[i][j] = A[i][j];
Rep(i, 1, m) Rep(j, 1, n) Sb[i][j] = B[i][j];
Rep(i, 1, n) sort(Sa[i] + 1, Sa[i] + m + 1);
Rep(i, 1, m) sort(Sb[i] + 1, Sb[i] + n + 1);
Rep(i, 1, n)
Rep(j, 1, m) {
int Num = A[i][j];
int x = lower_bound(Sa[i] + 1, Sa[i] + m + 1, Num) - Sa[i];
int y = lower_bound(Sb[j] + 1, Sb[j] + n + 1, Num) - Sb[j];
int xx = m - x + 1, yy = n - y + 1;
Answer[xx][yy] ++;
}
Rep(i, 1, q) {
int x = read(), y = read();
printf("%d\n", Answer[x][y]);
}
return 0;
}

noi.ac #36 模拟的更多相关文章

  1. NOI.AC NOIP模拟赛 第五场 游记

    NOI.AC NOIP模拟赛 第五场 游记 count 题目大意: 长度为\(n+1(n\le10^5)\)的序列\(A\),其中的每个数都是不大于\(n\)的正整数,且\(n\)以内每个正整数至少出 ...

  2. NOI.AC NOIP模拟赛 第六场 游记

    NOI.AC NOIP模拟赛 第六场 游记 queen 题目大意: 在一个\(n\times n(n\le10^5)\)的棋盘上,放有\(m(m\le10^5)\)个皇后,其中每一个皇后都可以向上.下 ...

  3. NOI.AC NOIP模拟赛 第二场 补记

    NOI.AC NOIP模拟赛 第二场 补记 palindrome 题目大意: 同[CEOI2017]Palindromic Partitions string 同[TC11326]Impossible ...

  4. NOI.AC NOIP模拟赛 第一场 补记

    NOI.AC NOIP模拟赛 第一场 补记 candy 题目大意: 有两个超市,每个超市有\(n(n\le10^5)\)个糖,每个糖\(W\)元.每颗糖有一个愉悦度,其中,第一家商店中的第\(i\)颗 ...

  5. NOI.AC NOIP模拟赛 第四场 补记

    NOI.AC NOIP模拟赛 第四场 补记 子图 题目大意: 一张\(n(n\le5\times10^5)\)个点,\(m(m\le5\times10^5)\)条边的无向图.删去第\(i\)条边需要\ ...

  6. NOI.AC NOIP模拟赛 第三场 补记

    NOI.AC NOIP模拟赛 第三场 补记 列队 题目大意: 给定一个\(n\times m(n,m\le1000)\)的矩阵,每个格子上有一个数\(w_{i,j}\).保证\(w_{i,j}\)互不 ...

  7. NOI.AC WC模拟赛

    4C(容斥) http://noi.ac/contest/56/problem/25 同时交换一行或一列对答案显然没有影响,于是将行列均从大到小排序,每次处理限制相同的一段行列(呈一个L形). 问题变 ...

  8. [NOI.AC 2018NOIP模拟赛 第三场 ] 染色 解题报告 (DP)

    题目链接:http://noi.ac/contest/12/problem/37 题目: 小W收到了一张纸带,纸带上有 n个位置.现在他想把这个纸带染色,他一共有 m 种颜色,每个位置都可以染任意颜色 ...

  9. NOI.AC NOIP模拟赛R3解题报告

    心路历程 预计得分:\(100+100+50=250\) 实际得分:\(10 +100 +50 = 160\) 三道原题,真好.T2做过,T1写了个错误思路,T3写了写50分状压dp. 整场考试实际在 ...

随机推荐

  1. response letter

    1.Firstly, we would like to thank you for your kind letter and for reviewers’ constructive commentsc ...

  2. Hadoop1-认识Hadoop大数据处理架构

    一.简介概述 1.什么是Hadoop Hadoop是Apache软件基金会旗下的一个开源分布式计算平台,为用户提供了系统底层细节透明的分布式基础架构 Hadoop是基于java语言开发,具有很好的跨平 ...

  3. 传统IDC 部署网站

    选择IDC机房 1.选择云主机. 2.传统IDC a购买服务器 b服务器托管 c装系统 装系统 虚拟机软件 vmware workstation virtualbox hyper-v 下载:r.ami ...

  4. 启动Nginx服务失败:Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

    首次接触nginx,安装完使用命令 service nignx restart  后,出现这个错误,并按照提示给出的命令查看错误详情  systemctl status nginx.service   ...

  5. sql 树形递归查询

    sql 树形递归查询: with ProductClass(ClassId,ClassName) as ( union all select c.ClassId,c.ClassName from Cl ...

  6. Find 命令记录

    当需要查找一个时间的文件时 使用find [文件目录] -mtime [时间] 例如:查看mysql.bak目录下的1天前的文件 find mysql.bak -mtime 找到此文件之后需要将它移动 ...

  7. hive 外部表和内部表的区别和相互转换

    Hive内部表和外部表区别 1.创建内部表时,内部表的数据文件是保存在指定的路径的:如若创建外部表,则只记录数据所在的路径,不会对数据位置做改变. 2.删除表的时候,内部表元数据和数据会跟着一起删除. ...

  8. Linux 绑定 ttyUSBn 串口方法。

    Linux 绑定 ttyUSBn 串口方法. 在linux下, 使用usb转串口, 经常会碰到一个问题: 如果有多个串口, 以不同顺序插入的时候, /dev/ttyUSB0 /dev/ttyUSB1的 ...

  9. Linux命令——e2fsck

    简介 e2fsck字面意义上理解时,Ext2 FileSystem Check,但他实际上不仅仅对Ext2有用,对Ext家族都有用,即Ext2/3/4d都也可以使用. 5 UNIX / Linux e ...

  10. css背景雪碧图等

    1.背景图 雪碧图技术 要设置背景,是要设置在某个盒子上 <!doctype html> <html lang="en"> <head> < ...