이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define nl "\n"
#define no "NO"
#define yes "YES"
#define fi first
#define se second
#define vec vector
#define task "main"
#define _mp make_pair
#define ii pair<int, int>
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define evoid(val) return void(std::cout << val)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)
#define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin())
using namespace std;
template<typename U, typename V> bool maxi(U &a, V b) {
if (a < b) { a = b; return 1; } return 0;
}
template<typename U, typename V> bool mini(U &a, V b) {
if (a > b) { a = b; return 1; } return 0;
}
const int mod = (int)1e9 + 7;
void prepare(); void main_code();
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
const bool MULTITEST = 0; prepare();
int num_test = 1; if (MULTITEST) cin >> num_test;
while (num_test--) { main_code(); }
}
void prepare() {};
const int N = (int)4100 + 9;
int cnt[N][4];
int cv(char c) {
if (c == 'A') return 0;
if (c == 'C') return 1;
if (c == 'G') return 2;
return 3;
}
int rel[N][N];
string s[N];
void main_code() {
int n, m, k;
cin >> n >> m >> k;
FOR(i, 1, n) {
cin >> s[i];
FOR(j, 0, m - 1) {
char c = s[i][j];
++cnt[j][cv(c)];
}
}
memset(rel, -1, sizeof rel);
vec<int> ch;
FOR(i, 1, n) {
int sum = 0;
FOR(j, 0, m - 1) {
int t = cv(s[i][j]);
FOR(l, 0, 3) if (l != t)
sum += cnt[j][l];
}
if (sum == k * (n - 1)) {
ch.push_back(i);
}
}
vec<int>nch;
for(int i:ch){
bool ok=1;
for(int j:ch)if (i!=j){
if (ok==0)break;
if (rel[i][j] != -1) {
ok &= rel[i][j];
continue;
}
int cx = 0;
FOR(t, 0, m - 1){
cx += s[i][t] != s[j][t];
if(cx>k)break;
}
rel[i][j]=rel[j][i]=(cx==k);
ok&=rel[i][j];
}
if(ok)nch.push_back(i);
}
if (sz(nch) == 1) {
cout << nch[0];
return ;
}
random_shuffle(all(nch));
for(int i : nch) {
bool ok=1;
FOR(j, 1, n) if (i!=j){
if (ok==0)break;
if (rel[i][j] != -1) {
ok &= rel[i][j];
continue;
}
int cx = 0;
FOR(t, 0, m - 1){
cx += s[i][t] != s[j][t];
if(cx>k)break;
}
rel[i][j]=rel[j][i]=(cx==k);
ok&=rel[i][j];
}
if (ok)evoid(i);
}
}
/* Let the river flows naturally */
컴파일 시 표준 에러 (stderr) 메시지
genetics.cpp: In function 'int main()':
genetics.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |