이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(8962);
int n, m, k;
char a[4105][4105];
bitset<4105> bs[4105];
bool mna(int x, int y)
{
int df = 0;
for (int i = 1; i <= m; i++)
if (a[x][i] != a[y][i])
df++;
if (df == k)
return true;
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (a[i][j] == 'C')
bs[i][j] = 1;
vector<int> candi;
for (int i = 1; i <= n; i++)
{
vector<int> alti;
for (int j = 1; j <= n; j++)
if (j != i)
alti.push_back(j);
shuffle(alti.begin(), alti.end(), default_random_engine(rng()));
bool ok = true;
int cate = 0;
for (auto it : alti)
{
if (!mna(i, it))
{
ok = false;
break;
}
cate++;
if (cate == 300)
break;
}
if (ok)
candi.push_back(i);
}
vector<int> candi2;
for (auto i : candi)
{
vector<int> alti;
for (auto j : candi)
if (j != i)
alti.push_back(j);
shuffle(alti.begin(), alti.end(), default_random_engine(rng()));
bool ok = true;
int cate = 0;
for (auto it : alti)
{
if (!mna(i, it))
{
ok = false;
break;
}
}
if (ok)
candi2.push_back(i);
}
if (candi2.size() == 1)
{
cout << candi2[0];
return 0;
}
for (auto i : candi2)
{
vector<int> alti;
for (int j = 1; j <= n; j++)
if (j != i)
alti.push_back(j);
shuffle(alti.begin(), alti.end(), default_random_engine(rng()));
bool ok = true;
int cate = 0;
for (auto it : alti)
{
if (!mna(i, it))
{
ok = false;
break;
}
}
if (ok)
{
cout << i;
return 0;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
genetics.cpp: In function 'int main()':
genetics.cpp:68:13: warning: unused variable 'cate' [-Wunused-variable]
68 | int cate = 0;
| ^~~~
genetics.cpp:93:13: warning: unused variable 'cate' [-Wunused-variable]
93 | int cate = 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... |