QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340119#1806. Character GridHKOI0#AC ✓131ms3612kbC++141.5kb2024-02-28 15:29:172024-02-28 15:29:17

Judging History

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

  • [2024-02-28 15:29:17]
  • 评测
  • 测评结果:AC
  • 用时:131ms
  • 内存:3612kb
  • [2024-02-28 15:29:17]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

char c[13][13];

int score() {
    set<string> S;
    for (int i = 0; i < 13; i++) {
        for (int j = 0; j < 12; j++) {
            string T; T += c[i][j]; T += c[i][j + 1];
            S.insert(T);
        }
    }
    for (int i = 0; i < 13; i++) {
        for (int j = 0; j < 12; j++) {
            string T; T += c[j][i]; T += c[j + 1][i];
            S.insert(T);
        }
    }
    return S.size();
}

void solve() {
    for (int i = 0; i < 13; i++) {
        for (int j = 0; j < 13; j++) {
            c[i][j] = 'a' + (i * (j * 2 + 1)) % 26;
        }
    }
    random_device rd;
    mt19937_64 rng(rd());
    int sc = score(), t = 0;
    while (sc < 13 * 24) {
        int k = rng() % 169; char nc = 'a' + rng() % 26;
        char oc = c[k / 13][k % 13];
        c[k / 13][k % 13] = nc;
        int nsc = score();
        if (nsc > sc) {
            sc = nsc;
        } else {
            c[k / 13][k % 13] = oc;
        }
        // if (t % 10000 == 0) {
        //     printf("time = %lld, score = %lld\n", t, sc);
        // }
        ++t;
    }

    cout << 13 << '\n';
    for (int i = 0; i < 13; i++) {
        for (int j = 0; j < 13; j++) {
            cout << c[i][j];
        }
        cout << '\n';
    }
}

int32_t main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int T = 1;
    // cin >> T;
    while (T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 131ms
memory: 3612kb

input:



output:

13
avtaagnhfaxga
bdfhjlnprtvzz
cgkoswweimquy
djpvbhntzflrx
emucksaiqygow
fpzjtdsxhrblv
gseqcopmykwiu
hvjxlznbpdrft
iyoeukfqgwmcs
jbtldvsfxphzr
keysmguuoicwq
lhdzvrljfbxtp
mkigecaywusqo

result:

ok accepted