QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369008#5254. Differencesqq11123334#WA 215ms62864kbC++201.7kb2024-03-27 19:20:072024-03-27 19:20:09

Judging History

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

  • [2024-03-27 19:20:09]
  • 评测
  • 测评结果:WA
  • 用时:215ms
  • 内存:62864kb
  • [2024-03-27 19:20:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 100005;
ll cnt1[N][4], cnt2[N][4], cnt3[N][4];
vector<vector<int>> v;
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m, k;
    cin >> n >> m >> k;

    v.resize(n + 1);

    for(int i = 1; i <= n; i++) {
        v[i].resize(m);
        for(int j = 0; j < m; j++) {
            char c;
            cin >> c;
            v[i][j] = (c - 'A');
        }
    }

    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < m; j++) {
            cnt1[j][v[i][j]]++;
            cnt2[j][v[i][j]] += (i);
            cnt3[j][v[i][j]] += (i * i);
        }
    }

    ll check1 = 0;
    ll check2 = 0;
    ll check3 = 0;
    for(int i = 1; i <= n; i++) {
        check1 += k;
        check2 += i * k;
        check3 += (i * i) * k;
    }
    vector<int> cand;
    for(int i = 1; i <= n; i++) {
        ll c1 = 0, c2 = 0, c3 = 0;
        for(int j = 0; j < m; j++) {
            for(int c = 0; c < 4; c++) {
                if(v[i][j] == c) continue;
                c1 += cnt1[j][c];
                c2 += cnt2[j][c];
                c3 += cnt3[j][c];
            }
        }

        if(check1 - k == c1 && check2 - i * k == c2 && check3 - i * i * k == c3) cand.push_back(i);
    }

    for(auto x : cand) {
        bool isable = true;
        for(int i = 1; i <= n; i++) {
            if(i == x) continue;
            ll dif = 0;
            for(int j = 0; j < m; j++) {
                if(v[x][j] != v[i][j]) dif++;
            }

            if(dif != k) isable = false;
        }

        if(isable) {
            cout << x << "\n";
            exit(0);
        }
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 215ms
memory: 62864kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result:

wrong answer 1st lines differ - expected: '1397', found: ''