이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (auto i = (l); i < (r); i++)
#define ForE(i, l, r) for (auto i = (l); i <= (r); i++)
#define FordE(i, l, r) for (auto i = (l); i >= (r); i--)
#define Fora(v, a) for (auto v: (a))
#define bend(a) (a).begin(), (a).end()
#define isz(a) ((signed)(a).size())
using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pii>;
using vvi = vector <vi>;
using ull = unsigned long long;
mt19937_64 rando(chrono::steady_clock::now().time_since_epoch().count());
const int N = 4100 + 5;
int valchar[256];
int n, m, k;
int a[N][N];
ull hshrow[N];
ull hshcolsame[N][5];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("KEK.inp", "r", stdin);
// freopen("KEK.out", "w", stdout);
valchar['A'] = 1;
valchar['C'] = 2;
valchar['G'] = 3;
valchar['T'] = 4;
cin >> n >> m >> k;
ForE(i, 1, n){
string s; cin >> s; s = ' ' + s;
ForE(j, 1, m){
a[i][j] = valchar[s[j]];
}
}
ForE(i, 1, n){
hshrow[i] = rando();
}
ForE(i, 1, n){
ForE(j, 1, m){
hshcolsame[j][a[i][j]] += hshrow[i];
}
}
ForE(i, 1, n){
ull hsh1 = 0, hsh2 = 0;
ForE(ti, 1, n){
if (ti == i){
continue;
}
hsh2 += hshrow[ti] * k;
}
ForE(j, 1, m){
ForE(c, 1, 4){
if (c != a[i][j]){
hsh1 += hshcolsame[j][c];
}
}
}
if (hsh1 == hsh2){
cout << i << endl;
return 0;
}
}
}
/*
==================================================+
INPUT: |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
OUTPUT: |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
*/
컴파일 시 표준 에러 (stderr) 메시지
genetics.cpp: In function 'int main()':
genetics.cpp:53:35: warning: array subscript has type 'char' [-Wchar-subscripts]
53 | a[i][j] = valchar[s[j]];
| ^
# | 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... |