QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#791109#5254. DifferenceskhanhtaiTL 0ms0kbC++232.1kb2024-11-28 16:56:242024-11-28 16:56:24

Judging History

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

  • [2024-11-28 16:56:24]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-28 16:56:24]
  • 提交

answer

#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 1000000007
#define inf 1e18
#define fi first
#define se second
#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 sz(a) ((int)(a).size())
#define endl '\n'
#define pi 3.14159265359
#define TASKNAME "differences"
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
using namespace std;
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;

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

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

        if (dif > k or same > m - k) return false;
    }
    return true;
}
main()
{
    fast;
    srand(time(NULL));
    if (fopen(TASKNAME".inp","r")){
        freopen(TASKNAME".inp","r",stdin);
        freopen(TASKNAME".out","w",stdout);
    }
//    cin >> n >> m >> k;
    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);

    }

    FOR(tim, 1, 200){
        random_shuffle(ord.begin(), ord.end());
    }



    FOR(i, 0, (int) ord.size() - 1){

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

            if (getDist(ord[i], ord[j]) == false) {
                ch = false;
                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.
**/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: