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的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...
随机推荐
- label自适应
//label自适应 self.label = [UILabel new]; self.label.font = [UIFont systemFontOfSize:14]; NSString *tit ...
- wpf CollectionViewSource的运用
实体类: 员工类: public class Department : ObservableCollection<Employee> { public string DepName { g ...
- Java中的一些术语的解释
一 API(Application Programming Interface,应用程序编程接口) 简单来说,就是其他人开发出来一块程序,你想用,他会告诉你调用哪个函数,给这个函数传什么参数,然后又 ...
- 【多重背包模板】poj 1014
#include <iostream> #include <stdio.h> #include <cstring> #define INF 100000000 us ...
- linux视频学习7(ssh, linux启动过程分析,加解压缩,java网络编程)
回顾数据库mysql的备份和恢复: show databases; user spdb1; show tables; 在mysql/bin目录下 执行备份: ./mysqldump -u root - ...
- 设计模式-中介者模式(Mediator)
/***中介者模式在消息队列中的应用*/package test.mediator; public abstract class Message { private Messages messages ...
- sql 日结
--生成日结数据 ==================================== -- Author: <Author,,Name> -- Create date: <Cr ...
- sql 按时间二段排序
业务需用为数据按倒序排序,当天数据排在以往日期前面,但当天数据需按小时进行升序排列 select *from( select vcTitle,dtBeginDate,case when dtBegin ...
- 通过ReconstructMe实现3D扫描
实物3D建模 目前在3D游戏制作过程中,需要专业人士花几天甚至数星期的时间,借助于Autodesk 3ds Max和Maya等昂贵的软件工具制作3D模型.纹理和动画.游戏制作中经常使用一种方法,即设计 ...
- 【gcd】 最大公约数
int gcd(int a,int b) { int r; ) { r=a%b; a=b; b=r; } return a; }