ZOJ 3955 Saddle Point】的更多相关文章

排序. 枚举每一个格子,计算这个格子在多少矩阵中是鞍点,只要计算这一行有多少数字比他大,这一列有多少数字比他小,方案数乘一下就是这个格子对答案做出的贡献. #include<bits/stdc++.h> using namespace std; int n,m; ; ][]; ][]; ][]; ]; struct X { int id,val; }s[]; bool cmp1(X a,X b) { return a.val<b.val; } bool cmp2(X a,X b) { r…
ZOJ3955 题意是这样的 给定一个n*m的整数矩阵 n和m均小于1000 对这个矩阵删去任意行和列后剩余一个矩阵为M{x1,x2,,,,xm;y1,y2,,,,,yn}表示删除任意的M行N列 对于这个剩下的矩阵,我们考虑其中是否存在特殊的元素,保证这些元素是所在行最大,所在列最小的元素 且非之一. 求对于所有删法,上述元素个数之和 对10^9+7取余. 显然所有删法 有2^(n+m)种 暴力是搞不定的. 于是反过来看,矩阵的元素最多有10^6个 是不是可以考虑每一个元素对最终答案的贡献? 所…
Chiaki has an n × m matrix A. Rows are numbered from 1 to n from top to bottom and columns are numbered from 1 to m from left to right. The element in the i-th row and the j-th column is Ai, j. Let M({i1, i2, ..., is}, {j1, j2, ..., jt}) be the matri…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3955 题意:给出一个n*m的矩阵,定义矩阵中的特殊点Aij当且仅当Aij是这一行最小的唯一元素,是这一列最大的唯一元素.删除一些行和列,剩下的元素构成的矩阵一共有(2^n-1)* (2^m-1)种,求这些矩阵的特殊点的个数. 思路:对于这种问题,可以考虑每一个点对答案的贡献. 其实就只是对于每一个点,找出在该行大于它的点的数目a,在该列大于它的点的数目b,然后该点对于答案…
Chiaki has an n × m matrix A. Rows are numbered from 1 to n from top to bottom and columns are numbered from 1 to m from left to right. The element in the i-th row and the j-th column is Ai, j. Let M({i1, i2, ..., is}, {j1, j2, ..., jt}) be the matri…
题意: 给出一个矩阵,删掉一些行和列之后 求剩下矩阵的鞍点的总个数 解析: 对于每个点 我们可以求出来 它所在的行和列  有多少比它大的 设为a 有多少比它小的 设为b 然后对于那些行和列 都有两种操作 删和不删 所以一个点 就有2^a * 2^b 种成为鞍点的存在形式 求出来所有的点的情况 加起来就好了 英语限制了我的想象力 #include <iostream> #include <cstdio> #include <sstream> #include <cs…
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5564   根据它的定义是行最小,列最大. 可以证明鞍点是唯一的. 单独考虑每一个元素的贡献,它能成为鞍点的情况有: 1.在这一行中,<= a[i][j]的元素肯定要删除,那么剩下k1个大于他a[i][j]的,当然a[i][j]本身不能删除 2.在这一列中,>= a[i][j]的元素肯定要删除,那么剩下k2个小于a[i][j]的,当然a[i][j]本身不能删除…
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3944 In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitre…
A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An…
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求输入的格式: START X Y Z END 这算做一个data set,这样反复,直到遇到ENDINPUT.我们可以先吸纳一个字符串判断其是否为ENDINPUT,若不是进入,获得XYZ后,吸纳END,再进行输出结果 2.注意题目是一个圆周,所以始终用锐角进行计算,即z=360-z; 3.知识点的误…