QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710917#7179. Fischer's Chess Guessing GametanphTL 0ms0kbC++202.5kb2024-11-04 23:05:532024-11-04 23:05:53

Judging History

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

  • [2024-11-04 23:05:53]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-04 23:05:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using i16 = short int;
using i32 = int32_t;
using i64 = int64_t;
using ui16 = unsigned short int;
using ui32 = uint32_t;
using ui64 = uint64_t;

template<class T>
using v = vector<T>;

#define all(a) (a).begin(), (a).end()
#define open(x) freopen(#x ".inp", "r", stdin), freopen(#x ".out", "w", stdout)

template<class X, class Y> bool mimi(X &x, const Y &y) {if(x > y) {x = y; return 1;} return 0;}
template<class X, class Y> bool mama(X &x, const Y &y) {if(x < y) {x = y; return 1;} return 0;}

const i32 N = 2 * 1e5;
const i32 M = 1e9 + 7;
const i32 inf = 1e9 + 9;
const i64 infll = 1e18 + 18;

string d = "RRNNBBKQ";
bool check(string &s) {
    v<i32> pos(5, -1);
    for (i32 i = 0; i < 8; i ++) {
        if (s[i] == 'R') pos[pos[0] == -1 ? 0 : 1] = i;
        if (s[i] == 'B') pos[pos[2] == -1 ? 2 : 3] = i;
        if (s[i] == 'K') pos[4] = i;
    }
    if (pos[0] > pos[4] || pos[1] < pos[4]) return false;
    if ((pos[2] & 1) == (pos[3] & 1)) return false;
    return true;
}

v<string> states;
i32 n = 960;
i32 cnt[960 + 1][960 + 1];

void sad(i32 testID) {
    for (i32 i = 0; i < n; i ++)
        for (i32 j = 0; j < n; j ++)
            for (i32 k = 0; k < 8; k ++)
                if (states[i][k] == states[j][k]) cnt[i][j] ++;

    string s;
    i32 huybeos;
    while (true) {
        cin >> s;
        if (s == "END") break;
        cin >> huybeos;
        i32 x = 0, idx = 0;
        v<i32> p(n);
        for(i32 i = 0; i < n; i ++) p[i] = i;
        cerr << 1 << endl;
        while (true) {
            if(p.size() == 1) {cout << states[p[0]] << endl; break;}
            i32 f = n + 1, r;
            for (i32 i = 0; i < n; i ++) { 
                v<i32> c(9, 0);
                for (i32 j : p) c[cnt[i][j]] ++;
                i32 m = *max_element(c.begin(), c.end());
                if (m < f) f = m, r = i;
            }
            cout << states[r] << endl;
            cin >> x;
            if(x == 8) break;
            v<i32> new_p;
            for (i32 i : p) if (cnt[i][r] == x) new_p.push_back(i);
            p = new_p;
        }
    }
}

i32 main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    sort(all(d));
    do {
        if (check(d)) states.push_back(d);
    } while (next_permutation(all(d)));
    states.resize(distance(states.begin(), unique(states.begin(), states.end())));

    i32 t = 1;
    for (i32 testID = 1; testID <= t; testID ++) {
        sad(testID);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

GAME 1
1
0
2
4
8
END

output:

NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
RKRBBQNN

result: