QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369013#5254. Differencesqq11123334#TL 1555ms69460kbC++201.3kb2024-03-27 19:23:302024-03-27 19:23:32

Judging History

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

  • [2024-03-27 19:23:32]
  • 评测
  • 测评结果:TL
  • 用时:1555ms
  • 内存:69460kb
  • [2024-03-27 19:23:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 100005;
int cnt[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);

    for(int i = 0; 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 = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cnt[j][v[i][j]]++; 
        }
    }

    vector<int> cand;
    for(int i = 0; i < n; i++) {
        ll dif = 0;
        for(int j = 0; j < m; j++) {
            for(int c = 0; c < 4; c++) {
                if(v[i][j] == c) continue;
                dif += cnt[j][c];
            }
        }

        if((n - 1) * k == dif) cand.push_back(i);
    }

    for(auto x : cand) {
        bool isable = true;
        for(int i = 0; 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 + 1 << "\n";
            exit(0);
        }
    }

}

詳細信息

Test #1:

score: 100
Accepted
time: 1555ms
memory: 61124kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:

1397

result:

ok single line: '1397'

Test #2:

score: 0
Accepted
time: 190ms
memory: 69460kb

input:

4099 4100 2
ABABBAAABBBABBBAABAAAAABABBBBBAAAAABBABBBBABBAAABBAABAAAAAAAAABBABAABAABBAAABAAAABBAABBBBABAAABAABABBAAABBBBBABABBBBBABBABBAABBBABAAABBABBBBAAAABAABBAABAABABABAAABAAAAABAABABBBAAAABBBBBBBABBBAABABBABABBBABAAAAABBBBABAAABABBBAABBAABBBABBABBBABBAABABBABBBBABBBABAABBBAAABAABAABBABAAABABABAB...

output:

2964

result:

ok single line: '2964'

Test #3:

score: 0
Accepted
time: 208ms
memory: 68020kb

input:

4002 4096 2048
ABBBAAABAABBBABBBBABBBBBBBAABBABBBAABABBABBABBABBAABABBBBBAAAAABBBBBBAAAAAABAAAABBBABABAABBBABABAAAABBAABAABABBBABBBBABAAAABBBBBBABBBAAABABBABABAABBABAAABABBABABABAAAAAABABAABABAABBAAAABAAAAABBABAABBAAAAAAABBAAAAABABBABABAAAAABBABBBBBABABAABABBBAABBAAABBBBAAAAABBBBBBBABBBAABBAABBAABBB...

output:

3926

result:

ok single line: '3926'

Test #4:

score: -100
Time Limit Exceeded

input:

3892 4096 3072
CCBACBACABCBBCDBDBBDDABDADCDCCAABAAADADDCBABABACAACCADDDAAACBCDACCBDBCCCACACBBBCADBBDBABDACAABADBBBADADADBAADBCCDBDAADCCBDCBDBAACAABDABDAADBBCDDCADDBBDBDBDDBBDACCCCACBACCBADDCCDCDCCACBCDDCDCCCADCDDAADBBDABAADBDDDACBDBDDDBACDAABBBDDABACAACDAADBBBCDCCCAAAADDCBDBBCBDDADCAACCAABBCCBDBABCB...

output:


result: