QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710922#7179. Fischer's Chess Guessing GametanphAC ✓128ms7444kbC++202.6kb2024-11-04 23:10:352024-11-04 23:10:35

Judging History

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

  • [2024-11-04 23:10:35]
  • 评测
  • 测评结果:AC
  • 用时:128ms
  • 内存:7444kb
  • [2024-11-04 23:10:35]
  • 提交

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[0] == 'E') break;
        cin >> huybeos;
        i32 x = 0, idx = 0;
        v<i32> p(n);
        for(i32 i = 0; i < n; i ++) p[i] = i;
        while (true) {
            if(p.size() == 1) {
                cout << states[p[0]] << endl; 
                cin >> x;
                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;
}

详细

Test #1:

score: 100
Accepted
time: 21ms
memory: 7244kb

input:

GAME 1
1
0
2
4
8
END

output:

NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
RKRBBQNN

result:

ok (c) correct after 1 tests, max moves 5 (1 test case)

Test #2:

score: 0
Accepted
time: 116ms
memory: 7300kb

input:

GAME 1
1
0
2
4
8
GAME 2
2
3
3
1
1
8
GAME 3
1
0
1
2
8
GAME 4
1
0
2
2
1
8
GAME 5
2
3
4
2
8
GAME 6
2
2
4
0
0
8
GAME 7
0
2
3
2
0
8
GAME 8
1
3
3
0
8
GAME 9
0
3
3
0
8
GAME 10
0
3
3
1
8
GAME 11
0
5
1
0
8
GAME 12
1
2
2
1
0
8
GAME 13
1
1
5
1
8
GAME 14
0
4
4
3
8
GAME 15
1
2
1
2
1
8
GAME 16
1
0
3
1
0
8
GAME 17...

output:

NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
RKRBBQNN
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBRNNQKR
BBNNRKQR
RKRBBNQN
NRBBNKQR
BRNNKBQR
NBRKNQBR
BNRKQRNB
RKRBBNNQ
NRBBNKQR
BRNNKBQR
NBRKNQBR
QBRKBRNN
BBNNQRKR
RKRBQNBN
NRBBNKQR
RNBBQKRN
RQKBNNBR
QNRBBKNR
RKRBNQBN
NRBBNKQR
RNBBQKRN
QNRBKNBR
BBNNQRKR
BBNNRKQR
RKRBNNBQ
NRB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #3:

score: 0
Accepted
time: 124ms
memory: 7304kb

input:

GAME 1
2
2
3
1
2
8
GAME 2
2
2
2
5
2
8
GAME 3
3
1
4
2
8
GAME 4
3
1
3
1
1
8
GAME 5
2
3
5
2
8
GAME 6
3
1
3
0
2
8
GAME 7
1
3
5
1
8
GAME 8
1
3
3
4
8
GAME 9
2
1
3
2
3
8
GAME 10
2
1
0
0
4
8
GAME 11
2
1
1
3
2
8
GAME 12
1
4
3
4
8
GAME 13
0
2
2
3
8
GAME 14
1
1
2
2
2
8
GAME 15
0
1
0
1
8
GAME 16
0
2
2
1
8
GAME ...

output:

NRBBNKQR
RNBBQKRN
QNRBKNBR
BNNQRBKR
BBQNNRKR
RKQBBNNR
NRBBNKQR
RNBBQKRN
QNRBKNBR
RBNNBQKR
BBNNQRKR
RKNBBQNR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BRKRNNQB
RKNBBNQR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BBRNKNRQ
BBNNRKQR
RKQBNNBR
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBNNRKQR
RKNBQNBR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BBRNKNRQ
BBNQRKNR
RKN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #4:

score: 0
Accepted
time: 114ms
memory: 7304kb

input:

GAME 1
1
2
1
4
0
8
GAME 2
3
1
0
1
8
GAME 3
2
0
3
0
8
GAME 4
1
1
0
1
0
8
GAME 5
2
0
4
0
0
8
GAME 6
3
0
1
0
8
GAME 7
2
1
1
0
8
GAME 8
2
2
1
1
0
8
GAME 9
3
0
0
6
8
GAME 10
2
0
4
1
0
8
GAME 11
2
1
3
1
1
8
GAME 12
3
0
0
4
8
GAME 13
2
2
1
1
2
8
GAME 14
3
1
4
5
8
GAME 15
2
1
1
3
1
8
GAME 16
1
3
0
4
8
GAME ...

output:

NRBBNKQR
BRNNKBQR
BNRBKRQN
BRKQNBNR
BBNNQRKR
QRKRBBNN
NRBBNKQR
RBBNQKRN
BQNBRNKR
BNQRKRNB
NRKRBBQN
NRBBNKQR
RNBBQKRN
BRKQNRNB
BBQNNRKR
NRKRBBNQ
NRBBNKQR
BRNNKBQR
RKQNRBBN
BBRKNNRQ
BBNNQRKR
QRKRBNNB
NRBBNKQR
RNBBQKRN
BRKQNRNB
BBNQRNKR
BBNNQRKR
NRKRBQNB
NRBBNKQR
RBBNQKRN
BNRBQNKR
BBNQNRKR
NRKRBNQB
NRB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #5:

score: 0
Accepted
time: 119ms
memory: 7444kb

input:

GAME 1
0
4
5
2
8
GAME 2
0
3
0
2
8
GAME 3
0
4
5
3
8
GAME 4
0
5
1
3
8
GAME 5
0
4
4
2
8
GAME 6
0
6
4
1
8
GAME 7
1
0
2
5
8
GAME 8
3
4
1
3
8
GAME 9
2
2
0
0
2
8
GAME 10
0
1
0
2
8
GAME 11
1
2
3
1
3
8
GAME 12
0
2
4
0
8
GAME 13
1
0
4
2
1
8
GAME 14
0
3
1
1
8
GAME 15
1
1
2
1
3
8
GAME 16
2
2
0
1
1
8
GAME 17
1
0...

output:

NRBBNKQR
RKNNRQBB
QNRKRBBN
BBNNRKRQ
RQNKRBBN
NRBBNKQR
RKNNRQBB
BQRNKRNB
NRKQRNBB
RNQKRBBN
NRBBNKQR
RKNNRQBB
QNRKRBBN
BBNNRKRQ
RNNKRBBQ
NRBBNKQR
RKNNRQBB
BBNRKQRN
BBNQRNKR
RQNKRNBB
NRBBNKQR
RKNNRQBB
QNRKRBBN
BBRKQNRN
RNQKRNBB
NRBBNKQR
RKNNRQBB
BNNRKQRB
BBNNQRKR
RNNKRQBB
NRBBNKQR
BRNNKBQR
NBRKNQBR
QBR...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #6:

score: 0
Accepted
time: 112ms
memory: 7300kb

input:

GAME 1
3
3
1
2
0
8
GAME 2
3
4
0
0
8
GAME 3
4
3
1
0
8
GAME 4
3
2
0
3
8
GAME 5
3
3
0
2
1
8
GAME 6
4
2
0
1
8
GAME 7
1
3
1
1
1
8
GAME 8
2
2
0
4
0
8
GAME 9
2
1
5
1
8
GAME 10
1
2
0
2
1
8
GAME 11
2
1
5
0
8
GAME 12
2
1
6
2
8
GAME 13
3
0
2
3
2
8
GAME 14
2
1
3
5
4
8
GAME 15
4
2
4
4
8
GAME 16
4
1
4
5
8
GAME 17...

output:

NRBBNKQR
RBBNQKRN
BBQRNKNR
BBNRQKRN
BBNNRKQR
QRBKNBRN
NRBBNKQR
RBBNQKRN
BBNNRQKR
BBNQRKNR
NRBKQBRN
NRBBNKQR
BNRBNKRQ
BNNRQBKR
BNRBQKNR
NRBKNBRQ
NRBBNKQR
RBBNQKRN
BBNQRKNR
BQRKNRNB
QRBKNNRB
NRBBNKQR
RBBNQKRN
BBQRNKNR
BBRNKNRQ
BBNNQRKR
NRBKQNRB
NRBBNKQR
BNRBNKRQ
BBNNRKQR
BBNQRKRN
NRBKNQRB
NRBBNKQR
BRN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #7:

score: 0
Accepted
time: 119ms
memory: 7340kb

input:

GAME 1
1
1
2
2
1
8
GAME 2
2
3
1
1
3
8
GAME 3
1
2
2
3
2
8
GAME 4
0
3
3
3
8
GAME 5
0
3
2
1
8
GAME 6
0
4
1
4
8
GAME 7
2
4
2
0
8
GAME 8
3
3
0
1
1
8
GAME 9
2
4
3
2
8
GAME 10
1
2
2
1
1
8
GAME 11
1
1
1
8
GAME 12
2
3
1
0
2
8
GAME 13
1
2
4
3
8
GAME 14
1
1
4
1
1
8
GAME 15
1
2
4
4
8
GAME 16
0
5
2
3
8
GAME 17
0...

output:

NRBBNKQR
BRNNKBQR
RKQNRBBN
BBRNQKRN
BBNNRKQR
RBBQKRNN
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBNRNKRQ
BBNNQRKR
RBBNKRQN
NRBBNKQR
BRNNKBQR
BNRBKRQN
BBNNRKRQ
BBNQNRKR
RBBNKRNQ
NRBBNKQR
RKNNRQBB
BQRNKRNB
NQNRKRBB
RBQNKRBN
NRBBNKQR
RKNNRQBB
BQRNKRNB
QRNKBNRB
RBNQKRBN
NRBBNKQR
RKNNRQBB
QNRKRBBN
BBNNQRKR
RBNNKRBQ
NRB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #8:

score: 0
Accepted
time: 128ms
memory: 7252kb

input:

GAME 1
3
0
3
3
8
GAME 2
4
1
2
2
8
GAME 3
4
1
2
4
8
GAME 4
2
0
1
2
3
8
GAME 5
3
1
1
2
2
8
GAME 6
3
0
1
3
3
8
GAME 7
0
0
6
3
8
GAME 8
1
4
1
5
8
GAME 9
0
1
4
4
8
GAME 10
1
2
6
2
8
GAME 11
2
3
1
1
2
8
GAME 12
1
2
6
1
8
GAME 13
0
2
0
3
8
GAME 14
0
1
5
2
8
GAME 15
1
4
2
3
8
GAME 16
0
2
0
2
8
GAME 17
1
1
2...

output:

NRBBNKQR
RBBNQKRN
BNRBQNKR
BQNBNRKR
QRNBKNBR
NRBBNKQR
BNRBNKRQ
NQBRNBKR
BBNRKQNR
NRQBKNBR
NRBBNKQR
BNRBNKRQ
NQBRNBKR
BBNRKQNR
NRNBKQBR
NRBBNKQR
RNBBQKRN
BRKQNRNB
BBRQKNNR
BBNNQRKR
QRNNKBBR
NRBBNKQR
RBBNQKRN
BQNBRNKR
BBRNNQKR
BBNNQRKR
NRQNKBBR
NRBBNKQR
RBBNQKRN
BNRBQNKR
BBNQNRKR
BBNQRKNR
NRNQKBBR
NRB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #9:

score: 0
Accepted
time: 106ms
memory: 7276kb

input:

GAME 1
2
1
0
3
2
8
GAME 2
3
2
3
2
8
GAME 3
4
0
1
3
8
GAME 4
1
3
3
3
3
8
GAME 5
2
0
0
2
2
8
GAME 6
2
0
0
2
3
8
GAME 7
2
2
4
1
1
8
GAME 8
3
1
2
3
1
8
GAME 9
4
1
5
1
8
GAME 10
1
4
4
2
8
GAME 11
2
0
0
4
2
8
GAME 12
2
1
1
1
2
8
GAME 13
3
6
1
2
8
GAME 14
2
6
3
8
GAME 15
3
6
2
3
8
GAME 16
1
1
4
1
2
8
GAME ...

output:

NRBBNKQR
RNBBQKRN
NRNKBRQB
BBRKRNNQ
BBNNQRKR
QBBRKNNR
NRBBNKQR
RBBNQKRN
BBNQRKNR
BBNRQKRN
NBBRKQNR
NRBBNKQR
BNRBNKRQ
BRNKQBNR
BBNNRKQR
NBBRKNQR
NRBBNKQR
BRNNKBQR
RBQNBNKR
BBNQRKNR
BBNNQRKR
QBNRKNBR
NRBBNKQR
RNBBQKRN
BRKQNRNB
BQRNKBNR
BBNNQRKR
NBQRKNBR
NRBBNKQR
RNBBQKRN
BRKQNRNB
BQRNKBNR
BBNNQRKR
NBN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #10:

score: 0
Accepted
time: 119ms
memory: 7232kb

input:

GAME 1
3
2
6
4
8
GAME 2
2
2
2
3
5
8
GAME 3
4
4
2
4
8
GAME 4
4
5
2
8
GAME 5
3
2
4
4
8
GAME 6
5
5
2
8
GAME 7
2
1
1
4
3
8
GAME 8
3
2
5
2
8
GAME 9
4
2
5
8
GAME 10
3
3
4
3
3
8
GAME 11
4
3
1
3
8
GAME 12
3
4
3
2
8
GAME 13
3
1
2
2
2
8
GAME 14
4
3
1
5
8
GAME 15
5
3
2
1
8
GAME 16
4
5
1
8
GAME 17
5
5
4
8
GAME ...

output:

NRBBNKQR
RBBNQKRN
BBNQRKNR
BBNNRKQR
BBRQNKNR
NRBBNKQR
RNBBQKRN
QNRBKNBR
RBNNBQKR
BBNNQRKR
BBRNQKNR
NRBBNKQR
BNRBNKRQ
BBNRKNRQ
BBNNQRKR
BBRNNKQR
NRBBNKQR
BNRBNKRQ
BBNNRKRQ
BQRBNKNR
NRBBNKQR
RBBNQKRN
BBNQRKNR
BRNBQKRN
BNRBQKNR
NRBBNKQR
BQRBNNKR
NQBBRNKR
BNRBNKQR
NRBBNKQR
RNBBQKRN
NRNKBRQB
BBNQRKNR
BBN...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Test #11:

score: 0
Accepted
time: 117ms
memory: 7216kb

input:

GAME 1
2
2
3
3
3
8
GAME 2
2
3
4
4
8
GAME 3
2
3
3
3
3
8
GAME 4
1
4
4
3
8
GAME 5
1
3
6
2
8
GAME 6
1
3
4
4
2
8
GAME 7
4
3
3
6
8
GAME 8
3
1
6
5
8
GAME 9
4
3
4
3
8
GAME 10
3
1
3
2
4
8
GAME 11
3
0
3
5
8
GAME 12
2
1
2
5
6
8
GAME 13
5
5
5
8
GAME 14
5
4
0
8
GAME 15
6
1
1
8
GAME 16
4
1
5
3
8
GAME 17
5
3
2
2
8...

output:

NRBBNKQR
RNBBQKRN
QNRBKNBR
BNNQRBKR
BBNNQRKR
RQNBBNKR
NRBBNKQR
RNBBQKRN
RQKBNNBR
QNRBBKNR
RNQBBNKR
NRBBNKQR
RNBBQKRN
RQKBNNBR
BBRNNQKR
BBNNQRKR
RNNBBQKR
NRBBNKQR
BRNNKBQR
QNBNRBKR
BBNQNRKR
RQNNBBKR
NRBBNKQR
BRNNKBQR
RBQNBNKR
BBNNRKQR
RNQNBBKR
NRBBNKQR
BRNNKBQR
RBQNBNKR
BBNQNRKR
BBNNRKQR
RNNQBBKR
NRB...

result:

ok (c) correct after 96 tests, max moves 6 (96 test cases)

Extra Test:

score: 0
Extra Test Passed