CodeForces 618B Guess the Permutation
只要找出当前没用过的数字中,大于或等于当前这一列的最大值就可以
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=;
int n;
int x[maxn][maxn];
int ans[maxn];
int flag[maxn]; int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++)
for(int j=; j<=n; j++)
scanf("%d",&x[i][j]); memset(flag,,sizeof flag); for(int j=; j<=n; j++)
{
int Max=-;
for(int i=; i<=n; i++) Max=max(Max,x[i][j]);
for(int i=Max; i<=n; i++)
{
if(flag[i]==)
{
ans[j]=i;
flag[i]=;
break;
}
}
}
for(int i=; i<=n; i++) printf("%d ",ans[i]);
printf("\n");
return ;
}
CodeForces 618B Guess the Permutation的更多相关文章
- 【CodeForces 618B】Guess the Permutation
题 题意 有个1到n的一个全排列,告诉你第i个数和全部n个数相比的较小的是哪个,和自己相比时为0,于是有个主对角线为0的矩阵,求原数列 分析 我的想法是,给我们的每一行之和按大小排一下,就知道第i个数 ...
- Codeforces 691D Swaps in Permutation
Time Limit:5000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Prac ...
- Codeforces 500B. New Year Permutation[连通性]
B. New Year Permutation time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- codeforces 500B.New Year Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/500/B 题目意思:给出一个含有 n 个数的排列:p1, p2, ..., pn-1, pn.紧接着是一个 ...
- codeforces B. Levko and Permutation 解题报告
题目链接:http://codeforces.com/problemset/problem/361/B 题目意思:有n个数,这些数的范围是[1,n],并且每个数都是不相同的.你需要构造一个排列,使得这 ...
- 【搜索】【并查集】Codeforces 691D Swaps in Permutation
题目链接: http://codeforces.com/problemset/problem/691/D 题目大意: 给一个1到N的排列,M个操作(1<=N,M<=106),每个操作可以交 ...
- [Codeforces 864D]Make a Permutation!
Description Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to ...
- Codeforces 785E. Anton and Permutation
题目链接:http://codeforces.com/problemset/problem/785/E 其实可以CDQ分治... 我们只要用一个数据结构支持单点修改,区间查询比一个数大(小)的数字有多 ...
- Codeforces 804E The same permutation(构造)
[题目链接] http://codeforces.com/contest/804/problem/E [题目大意] 给出一个1到n的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...
随机推荐
- 设计模式二 适配器模式 adapter
适配器模式的目的:如果用户需要使用某个类的服务,而这项服务是这个类用一个不同的接口提供的,那么,可以使用适配器模式为客户提供一个期望的接口.
- replication across two data centers
http://andyhan.net/index.php/sys-adm/item/291-hbase-replication http://shitouer.cn/2013/04/hbase-mul ...
- UIView的基本属性及ANimation
frame属性:可以使用该属性改变尺寸和位置 相对于父视图bounds:改变尺寸 相对自身center:改变视图的位置alpha:改变视图的透明度backgroundColor:改变视图的背景cont ...
- [转]c++ new带括号和不带括号
ref:http://m.blog.csdn.net/blog/u012745772/42420443 在new对象的时候有加上(),有不加(),不知道这个到底是什么区别?比如:CBase *base ...
- 直接用postman测试api ,服务器端没提供跨域也可以访问。
1. 直接用postman测试api ,服务器端没提供跨域也可以访问. 但是,如果用本地的 sever 搭的server, 然后去访问api的话,浏览器会提示 跨域错误.
- 为ubuntu添加右键打开终端效果
安装工具:nautilus-open-terminal sudo apt-get install nautilus-open-terminal 注销或重启
- ReactiveCocoa / RxSwift 笔记一
原创:转载请注明出处 ReactiveCocoa / RxSwift Native app有很大一部分的时间是在等待事件发生,然后响应事件,比如 1.等待网络请求完成, 2.等待用户的操作, 3.等待 ...
- 快学Scala-第六章 对象
知识点: 1.单例对象 使用object语法结构达到静态方法和静态字段的目的,如下例,对象定义某个类的单个实例,包含想要的特性,对象的构造器在该对象第一次被使用时调用. object Account{ ...
- HDU1162-Eddy's picture(最小生成树)
Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to become ...
- MongoDB如何设置权限(类似关系型数据库的用户名和密码)
MongoDB 缺省是没有设置鉴权的,业界大部分使用 MongoDB 的项目也没有设置访问权限.这就意味着只要知道 MongoDB 服务器的端口,任何能访问到这台服务器的人都可以查询和操作 Mongo ...