20200725 PAT甲级 7-2 The Judger (25分)

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int exist[100010]={0}, diff[100010] = {0};
// exist记录已经报过的数，diff记录已经报过的数的差值
vector<int> exists;
// exists记录已经报过的数，对于每个新报的数，和每个已存的数相减得差
int ht[15] = {0};
int a[1010][1010];

int main() {

int n1, n2;
scanf("%d%d", &n1, &n2);

diff[abs(n1 - n2)] = 1;
exist[n1] = 1;
exist[n2] = 1;
exists.push_back(n1);
exists.push_back(n2);

int n, m;
scanf("%d%d", &n, &m);

for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
scanf("%d", &a[i][j]);

for(int j = 1; j <= m; j++) {
for(int i = 1; i <= n; i++) {

if(ht[i] == 1) continue;

int t = a[i][j];

if(diff[t] && !exist[t]) {

for(int i = 0; i < exists.size(); i++) {
int t2 = exists[i];
diff[abs(t - t2)] = 1;
}
exist[t] = 1;
exists.push_back(t);
} else {
ht[i] = 1;
printf("Round #%d: %d is out.\n", j, i);
}
}
}

int f = 1;
for(int i = 1; i <= n; i++) {
if(ht[i] == 0) {
if(f) printf("Winner(s):");
printf(" %d", i);
f = 0;
}
}
if(f) printf("No winner.");

return 0;
}


09-09 459

03-28 1485

07-25 1166

12-08 188

05-06 73

08-26 207

02-19 66

02-14 97

02-13 111

03-20 905

杂题（大部分网络流+暴力）

©️2020 CSDN 皮肤主题: 深蓝海洋 设计师: CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。