QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595108#5254. Differenceshzy99999#TL 0ms0kbC++201.4kb2024-09-28 12:36:152024-09-28 12:36:16

Judging History

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

  • [2024-09-28 12:36:16]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-09-28 12:36:15]
  • 提交

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <chrono>
#include <random>
#include <iomanip>
#define chmx(x, y) x=max(x,y)
#define chmn(x, y) x=min(x,y)
//#define x first
//#define y second
using namespace std;
const int N = 2e5 + 5;
const int P = 131;
const int M = 1e6 + 10;
const int mod = 123456789;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef pair<ll, ll>PII;
int n, m, k, ans;
int st[100010];
string s[100010];
int dis(string a, string b) {
    int res = 0;
    for (int i = 0; i < m; i++) {
        res += (a[i] != b[i]);
    }
    return res;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)cin >> s[i];
    queue<int>q;
    q.push(0);
    while (q.size()) {
        auto t = q.front();
        q.pop();
        if (st[t])continue;
        bool flag = 1;
        for (int i = 0; i < n; i++) {
            if (i == t)continue;
            int d = dis(s[i], s[t]);
            if (d != k) {
                flag = 0;
                st[i] = 1;
                st[t] = 1;
            }
            else {
                q.push(i);
            }
        }
        if (flag) {
            cout << t + 1 << '\n';
            break;
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: