AcWing 4858. 裁判机
原题链接
简单
作者:
YAX_AC
,
2024-12-11 22:07:01
,
所有人可见
,
阅读 5
//duplicated复制,重复 or even甚至 kicked踢
//The number must be the difference of two numbers that are previously given
//and must not be duplicated to any of the existed numbers.
//该数字必须是之前给出的两个数字的差值,并且不得与任何现有数字重复
//题⽬要求是给出的数字必须是前⾯已经出现的某两个正整数之差,
//可以转换为现在这个⼈出的数字,加上已经出过的某个数,看是不是等于另⼀个已经出过的数字
//如果这个数加所有出现过数字,不等于另外⼀个已经出现过的数字,或者这个数已经出现过了,那么这个⼈淘汰
#include<bits/stdc++.h>
using namespace std;
int N, M, flag2, A[11][1001], mark[200005], out[11];
vector<int> used(2);
int main()
{
cin >> used[0] >> used[1];
mark[used[0]] = mark[used[1]] = 1;
cin >> N >> M;
for (int i = 1; i <= N; i++)
for (int j = 1; j <= M; j++)
cin >> A[i][j];
for (int i = 1; i <= M; i++)
for (int j = 1; j <= N; j++)
{
if (out[j]) continue;
int flag = 0;
if (mark[A[j][i]]) flag = -1;
for (auto it : used)
{
if (mark[it + A[j][i]] == 1)
{
mark[A[j][i]] = 1;
flag++;
used.push_back(A[j][i]);
break;
}
}
if (flag <= 0)
{
out[j] = 1;
cout << "Round #" << i << ": " << j << " is out.\n";
}
}
for (int i = 1; i <= N; i++)
{
if (!out[i])
{
if(!flag2)
{
cout << "Winner(s):";
flag2 = 1;
}
cout << " " << i;
}
}
if (!flag2) cout << "No winner.";
return 0;
}