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>
#define int long long
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 123;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
void Fastio()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n, m, k;
int a[4105][4105];
int x[4105];
int f[4105][4];
signed main()
{
Fastio();
cin >> n >> m >> k;
x[0] = 1;
for(int i = 1; i < n; i++)
{
x[i] = 1ll * x[i - 1] * p % mod;
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
char temp;
cin >> temp;
if(temp == 'A')
{
a[i][j] = 0;
}
else if(temp == 'T')
{
a[i][j] = 1;
}
else if(temp == 'G')
{
a[i][j] = 2;
}
else
{
a[i][j] = 3;
}
f[j][a[i][j]] += x[i];
f[j][a[i][j]] %= mod;
}
}
for(int i = 0; i < n; i++)
{
int temp = 0, cur = 0;
for(int j = 0; j < m; j++)
{
for(int t = 0; t < 4; t++)
{
if(t != a[i][j])
{
temp = temp + f[j][t];
temp = (temp + mod) % mod;
}
}
}
for(int j = 0; j < n; j++)
{
if(j != i)
{
int r = 1ll * (x[j] * k) % mod;
cur = (cur % mod + r + mod) % mod;
}
}
if(temp == cur)
{
cout << i + 1;
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... |