QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#507205#5254. Differencesthangthang#TL 213ms25628kbC++201.2kb2024-08-06 13:36:302024-08-06 13:36:31

Judging History

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

  • [2024-08-06 13:36:31]
  • 评测
  • 测评结果:TL
  • 用时:213ms
  • 内存:25628kb
  • [2024-08-06 13:36:30]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n, m, k, cnt[N][4];
string s[N];

void solve(){
    srand(time(NULL));
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++ i){
        cin >> s[i];
        for (int j = 0; j < m; ++ j) cnt[j][s[i][j] - 'A'] ++;
    }

    vector <int> candidate;
    for (int i = 1; i <= n; ++ i){
        long long dist = 0;
        for (int j = 0; j < m; ++ j) dist += (n - cnt[j][s[i][j] - 'A']);
        if (dist == 1ll * k * (n - 1)){
            candidate.push_back(i);
            //return;
        }
    }

    random_shuffle(candidate.begin(), candidate.end());
    for (int u : candidate){
        bool ck = true;
        for (int i = 1; i <= n; ++ i){
            if (i == u) continue;
            int dist = 0;
            for (int j = 0; j < m; ++ j) dist += (s[u][j] != s[i][j]);
            if (dist != k){
                ck = false;
                break;
            }
        }
        if (ck) {
            cout << u;
            return;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 213ms
memory: 23564kb

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:

1397

result:

ok single line: '1397'

Test #2:

score: 0
Accepted
time: 53ms
memory: 25276kb

input:

4099 4100 2
ABABBAAABBBABBBAABAAAAABABBBBBAAAAABBABBBBABBAAABBAABAAAAAAAAABBABAABAABBAAABAAAABBAABBBBABAAABAABABBAAABBBBBABABBBBBABBABBAABBBABAAABBABBBBAAAABAABBAABAABABABAAABAAAAABAABABBBAAAABBBBBBBABBBAABABBABABBBABAAAAABBBBABAAABABBBAABBAABBBABBABBBABBAABABBABBBBABBBABAABBBAAABAABAABBABAAABABABAB...

output:

2964

result:

ok single line: '2964'

Test #3:

score: 0
Accepted
time: 43ms
memory: 25628kb

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: