This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mxn = 3e5+5;
#define FAST ios_base::sync_with_stdio(0);cout.tie(0)
typedef long long ll;
bool vis[4105];
int pre[4105][2];
vector<string>arr;
int main()
{
// input;
// output;
FAST;
int n, m, k;
cin >> n >> m >> k;
vector<bitset<4105> >v;
for(int i = 0; i < n; i++)
{
string s;
cin >> s;
bitset<4105>tmp;
// cout << tmp << '\n';
for(int r = 0; r < m; r++)
{
if(s[r]=='A') tmp[r] = '1', s[r] = '1';
else s[r] = '0';
pre[r][s[r]-'0']++;
}
arr.push_back(s);
v.push_back(tmp);
}
//for(int i = 0; i < m; i++) cout << pre[i][0] << ' ' << pre[i][1] << '\n';
int ans = -1;
for(int i = 0; i < n; i++)
{
int cnt = 0;
if(vis[i]) continue;
int got = 0;
for(int r = 0; r < m; r++) {
if(arr[i][r]=='0') got+=pre[r][1];
else got+=pre[r][0];
}
if(got!= k*(n-1)) continue;
for(int r = 0; r < n; r++)
{
if(i==r) continue;
bitset<4105>tmp = v[i]^v[r];
int x = tmp.count();
if(x==k) cnt++;
else {
vis[r] = 1;
break;
}
}
if(cnt==n-1)
{
ans = i+1;
break;
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |