QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791553#5254. DifferenceskhanhtaiTL 0ms0kbC++231.7kb2024-11-28 19:29:292024-11-28 19:29:34

Judging History

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

  • [2024-11-28 19:29:34]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-28 19:29:29]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define TASKNAME "differences"
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("Ofast")
using namespace std;

const int MAXN = 1e5 + 9;
vector<vector<char>> str;
vector<int> ord;
int n, m, k, invalid[MAXN];

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 mt(seed);

main()
{
    fast;
    srand(time(NULL));
    scanf("%d %d %d", &n, &m, &k);
    str.resize(n);
    FOR(i, 0, n - 1){
        str[i].resize(m);
        FOR(j, 0, m - 1){
            scanf(" %c", &str[i][j]);
        }
        ord.pb(i);
    }

    shuffle(ord.begin(), ord.end(), default_random_engine(0));
    FOR(i, 0, (int) ord.size() - 1){

        bool ch = true;
        if (invalid[i]) continue;

        FOR(j, 0, (int) ord.size() - 1){
            if (j == i) continue;

            int same = 0, dif = 0;
            FOR(t, 0, m - 1){
                if (str[ord[i]][t] != str[ord[j]][t]) dif++;
                else same++;

                if (dif > k or same > m - k) {
                    invalid[j] = true;
                    invalid[i] = true;
                    ch = false;
                    break;
                }
            }
            if (!ch) break;
        }

        if (ch) {
            cout << ord[i] + 1<< endl;
            exit(0);
        }
    }

}
/**
Warning:
Đọc sai đề???
Cận lmao
Code imple thiếu case nào không.
Limit.
**/

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: