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的排列,问每两个位置都进行一次交换最终排列不变是否可能, 如果可能输出 ...
随机推荐
- 运用Merge Into实现增加或更新数据
declare @SqlStr as nvarchar(max) set @SqlStr=N'Merge Into [Categories] t USING(VALUES (9,''rice'','' ...
- Coupons and Discounts
Coupons and Discounts time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 实验用rootkit
进程对比实验用得到rootkit: 1.FU rootkit 简单的来说,FU是一个隐藏进程的工具.,FU_Rootkit是开源的,用C语言编写.FU_Rootkit主程序包括2个部分:Fu.exe和 ...
- 设计模式-中介者模式(Mediator)
/***中介者模式在消息队列中的应用*/package test.mediator; public abstract class Message { private Messages messages ...
- 在写一个iOS应用之前必须做的7件事
转载自:http://www.cocoachina.com/ios/20160316/15685.html 原文:https://medium.com/ios-os-x-development/7-t ...
- javascript语句语义大全(3)
1. for(var i=0;i<10;i++){ } for循环,括号里面是循环条件,翻译过来是,初始设定1=0:没循环一次i会+1,直到i<10 2. var i=0: while(i ...
- 使用Github搭建个人博客网站
1 新建一个repo,创建一个没有父节点的分支gh-pages(github规定,只有该分支中的页面,才会生成网页文件): mkdir jekyll_demo cd jekyll_demo git i ...
- 转:Selenium Grid深入学习
应网友要求写一个用Selenium Grid控制多系统多浏览器并行执行test case的例子. 因为我这里有两台机子,我打算这样演示: 一台机子启动一个作为主点节的hub 和 一个作为次节点的hub ...
- MFC的核心概念
API是英文Application Programming Interface 的缩写,意思是“应用程序接口”,泛指系统为应用程序提供的一系列函数接口,在编程时可以直接调用,而不必知道其内部实现的过程 ...
- O(n)线性时间找第K大,中位数
运用快速排序的思想,可以达到线性时间找到一串数的第K大 #include<cstdio> #define F(i,a,b) for(int i=a;i<=b;i++) ],n; vo ...