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;
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll N, M, K;
cin >> N >> M >> K;
vector<array<ll, 26>> freq(M);
vector<ll> v(N), freqTot(M);
vector<string> dnas(N);
for (auto &s : dnas) cin >> s;
for (auto &x : v) x = rng();
for (int i = 0; i < N; i++)
{
const auto &s = dnas[i];
for (int j = 0; s[j]; j++)
{
freq[j][s[j]] += v[i]; freqTot[j] += v[i];
}
}
ll soma = accumulate(v.begin(), v.end(), 0LL);
for (int i = 0; i < N; i++)
{
ll atual = 0;
const auto &s = dnas[i];
for (int j = 0; s[j]; j++)
atual += freqTot[j] - freq[j][s[j]];
if (atual == (K * (soma - v[i]))) {cout << i+1 << '\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... |