An Unfair Game-[ACdream1035]
Problem Description
Input
The input contains several test, and ends with EOF. For each test, the first line has an integer n,which is the number of people and target,next there is an integer matrix which size is n*n, the i-th row and the j-th colume of matrix means the time that i-th person needs to get target j. Next line is a number m, the number of the person who you want to be punished.
1<=m<n<=100
Output
Sample Input
3
1 2 3
2 3 4
3 4 5
3
3
3 3 3
2 2 2
1 1 1
3
Sample Output
2 3
-1
Source
Manager
#include<stdio.h>
#include<string.h>
int d[][],res[],N,M,q[];
bool f[][],sta[];
bool find(int a)
{
for (int i=;i<=N;i++)
{
if (f[a][i] && (!sta[i]))
{
sta[i]=true;
if (res[i]== || find(res[i]))
{
res[i]=a;
return true;
}
}
}
return false;
}
int hungary()
{
memset(res,,sizeof(res));
int Ans=;
for (int i=;i<=N;i++)
{
memset(sta,,sizeof(sta));
if (find(i)) Ans++;
}
return Ans;
}
int main()
{
while (scanf("%d",&N)!=EOF)
{
for (int i=;i<=N;i++)
for (int j=;j<=N;j++)
scanf("%d",&d[i][j]);
scanf("%d",&M);
int T=;
for (int i=;i<=N;i++)
{
memset(f,true,sizeof(f));
for (int j=;j<=N;j++) f[j][i]=false;
for (int j=;j<=N;j++) f[M][j]=false;
for (int j=;j<=N;j++)
for (int k=;k<=N;k++)
if (d[j][k]>=d[M][i]) f[j][k]=false;
if (hungary()==(N-)) q[++T]=i;
}
if (T==) printf("-1\n");
else
{
for (int i=;i<T;i++) printf("%d ",q[i]);
printf("%d\n",q[T]);
}
}
return ;
}
An Unfair Game-[ACdream1035]的更多相关文章
- Codeforces758C Unfair Poll 2017-01-20 10:24 95人阅读 评论(0) 收藏
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 【找规律】Codeforces Round #392 (Div. 2) C. Unfair Poll
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #392 (Div. 2) Unfair Poll
C. Unfair Poll time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- CodeForces 758 C Unfair Poll
Unfair Poll 题意:一共有n排同学每排同学有m个人, 老师问问题有一个顺序, 先从第一排开始问,问完第一排的所有同学之后,再问第2排的,对于所有排的访问顺序为 1,2,3……n-1,n,n- ...
- C. Unfair Poll
http://codeforces.com/problemset/problem/758/C C. Unfair Poll time limit per test 1 second memory li ...
- 【HDOJ】4317 Unfair Nim
基本的状态压缩,想明白怎么dp还是挺简单的.显然对n个数字进行状态压缩,dp[i][j]表示第i位状态j表示的位向高位产生了进位. /* 4317 */ #include <iostream&g ...
- CF758C Unfair Poll
题意: On the Literature lesson Sergei noticed an awful injustice, it seems that some students are aske ...
- C. Unfair Poll 数学题,
http://codeforces.com/contest/758/problem/C 需要一个能够找到任意一个位置的步数的方法,就能解决三个问题. 预处理出one(row, col)表示第一次经过这 ...
- 【codeforces 758C】Unfair Poll
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
随机推荐
- JAVA作业 字符变整型相加,整型输出
从命令行接收多个数字求和输出 一.设计思想 用输入语句输入两个字符串,分别转化成整型Integer.parseInt(string),相加,将结果再转化为字符串型String.valueOf(int) ...
- CLR via C#(12)-委托Delegate
本来按照进度应该学习事件了,可总觉得应该委托在前,事件在后,才好理解. 委托是一个类,它提供了回调函数机制,而且是类型安全的.使用委托可以将方法当作另一个方法的参数来进行传递,这种将方法动态地赋给参数 ...
- Android ANR分析(三)
http://www.jianshu.com/p/8964812972be http://stackoverflow.com/questions/704311/android-how-do-i-inv ...
- python中如何用dis模块来查看py的汇编代码?
之前测试不成功,用导入dis的方式. 但如何在命令行里加入 -m dis,就会OK啦. python -m dis test.py #coding: utf8 x = [1, 2, 3] for i ...
- 终于看完<LEARNING SQL>第二版,立此存照
- 2014百度之星资格赛 1004:Labyrinth(DP)
Labyrinth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- git branch用法总结
git branch git branch 不带参数:列出本地已经存在的分支,并且在当前分支的前面加“*”号标记,例如: #git branch* master newbranch ...
- PHP实现上一篇、下一篇
//php实现上一篇.下一篇 获取当前浏览文章id $id = isset($_GET[ ? intval($_GET['id']) : ""; 下一篇文章 $query = my ...
- WCF学习笔记之消息交换模式
在WCF通信中,有三种消息交换模式,OneWay(单向模式), Request/Reponse(请求回复模式), Duplex(双工通信模式)这三种通信方式.下面对这三种消息交换模式进行讲解. 1. ...
- [QCon] Scrum阅读随想
最近从群里面下载到几篇文章,看到QCon出来的相关文章,觉得都写的很不错,都是一些个大公司的非常好的方法 QCon:是为团队领导者.架构师.项目经理和高级软件开发人员量身打造的企业软件开发大会,其 ...