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 ...
随机推荐
- PHP数据库操作
PHP实现数据库的增删改查 <?php $conn=mysql_connect('localhost','root','root'); if(!$conn){ echo "connec ...
- poj 3461Oulipo
题目链接:http://poj.org/problem?id=3461 统计字符串出现的次数 #include<cstdio> #include<iostream> #incl ...
- kvm 网桥
root@ok Downloads]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 HWADDR=54:EE:75:4E:37: ...
- Delphi编译dll时出错"Cannot debug project unless a host application is defined.use the run|parameters...dialog box."
问题: 在编写DLL程序的时候,按下F9或者按下那个绿色的箭头,会报错,如下 原因: 是因为你按下的F9或者那个绿色箭头是表示“Run”这个程序,但是DLL不是可执行文件,所以当然不能够运行,所以就会 ...
- Linux Shell 高级编程技巧2----shell工具
2.shell工具 2.1.日志文件 简介 创建日志文件是很重要的,记录了重要的信息.一旦出现错误,这些信息对于我们排错是非常有用的:监控的信息也可以记录到日 ...
- ExcelReport第三篇:扩展元素格式化器
导航 目 录:基于NPOI的报表引擎——ExcelReport 上一篇:ExcelReport源码解析 概述 上篇中已介绍了ExcelRepor的架构,本篇将通过例子讲述如何扩展元素格式化器以满足 ...
- 在SQL里如何写条件逻辑?
主要涉及CASE,WHEN之类.. 不同的服务器上实现if...else...是不一样的. 建议用CASE ,WHEN,因为它们是SQL国标呢. mysql> SELECT -> SUM( ...
- hdu 1075:What Are You Talking About(字典树,经典题,字典翻译)
What Are You Talking About Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 102400/204800 K ...
- 安装oracle 10g RAC执行的几个脚本说明
1,/u01/app/oracle/oraInventory/orainstRoot.sh 脚本 #!/bin/sh if [ -d "/etc" ]; then /etc; fi ...
- nexus私有仓库搭建
步骤: 下载安装JDK(注意可用版本) .查看CentOS自带JDK是否已安装,输入: yum list installed |grep java 一般来说,如果是新装CentOS系统的话,不会有JD ...