QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#191650 | #5254. Differences | timreizin | RE | 0ms | 0kb | C++20 | 1.4kb | 2023-09-30 06:32:19 | 2023-09-30 06:32:21 |
answer
#include <vector>
#include <queue>
#include <list>
#include <iostream>
#include <array>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const ll P = 1e6 + 7;
const ll MOD = 1e9 + 9;
int main()
{
int n, m, k;
cin >> n >> m >> k;
vector<array<ll, 4>> ne(m, {0, 0, 0, 0});
vector<string> s(n);
vector<ll> powers;
ll power = 0, sum = 0;
for (string &i : s)
{
power = max(power * P % MOD, 1ll);
sum += power;
if (sum >= MOD)
sum -= MOD;
powers.push_back(power);
cin >> i;
for (int j = 0; j < m; ++j)
{
for (char k = 'A'; k <= 'D'; ++k)
{
if (i[j] == k)
continue;
ne[j][k - 'A'] += power;
if (ne[j][k - 'A'] >= MOD)
ne[j][k - 'A'] -= MOD;
}
}
}
for (int i = 0; i < n; ++i)
{
ll hash = 0;
for (int j = 0; j < m; ++j)
{
hash += ne[j][s[i][j] - 'A'];
if (hash >= MOD)
hash -= MOD;
}
if (hash == ((sum - powers[i]) * k) % MOD)
{
cout << i + 1 << '\n';
return 0;
}
}
assert(false);
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...