QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#191650#5254. DifferencestimreizinRE 0ms0kbC++201.4kb2023-09-30 06:32:192023-09-30 06:32:21

Judging History

你现在查看的是最新测评结果

  • [2023-09-30 06:32:21]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-09-30 06:32:19]
  • 提交

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...

output:


result: