QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#491777#7179. Fischer's Chess Guessing Gameno_RED_no_DEADTL 2ms3668kbC++202.4kb2024-07-25 22:01:592024-07-25 22:02:00

Judging History

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

  • [2024-07-25 22:02:00]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:3668kb
  • [2024-07-25 22:01:59]
  • 提交

answer

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

const ll N = 1e6 + 1;
const ll M = 1e9 + 7;

vector<string> v, res;
string S[] = {"NRBBNQKR", "RKBBNQRN", "BBNNQRKR", "BBRKNNRQ", ""};
ll val[N];

ll cal(string &s, string &t) {
    ll res = 0;
    for (int i = 0; i <= 7; i ++)
        if (s[i] == t[i]) res ++;
    return res;
}

void doTest(ll testID) {
    while (true) {
        bool nxt = 0;
        string tmp; cin >> tmp;
        if (tmp == "END") return;
        cin >> tmp;

        for (int i = 0; i < 4; i ++) {
            cout << S[i] << endl;
            cin >> val[i];
            if (val[i] == 8) {nxt = 1; break;}
        }
        if (nxt) continue;

        res.clear();
        for (auto x: v) {
            bool ok = 1;
            for (int i = 0; i < 4; i ++)
                if (cal(x, S[i]) != val[i]) {ok = 0; break;}
            if (ok) res.push_back(x);
        }

        for (auto x: v) {
            set<ll> s;
            for (auto y: res) s.insert(cal(x, y));
            if (s.size() == res.size()) {
                S[4] = x;
                cout << S[4] << endl;
                cin >> val[4];
                if (val[4] == 8) {nxt = 1; break;}
                break;
            }
        }
        if (nxt) continue;

        for (auto x: v) {
            bool ok = 1;
            for (int i = 0; i < 5; i ++)
                if (cal(x, S[i]) != val[i]) {ok = 0; break;}
            if (ok) {
                cout << x << endl;
                cin >> tmp;
                break;
            }
        }
    }
}

signed main() {    
    // freopen("a.inp", "r", stdin);
    // freopen("a.out", "w", stdout);

    set<string> s;
    string T = "KNNBBRRQ";
    sort(T.begin(), T.end());
    do {
        vector<ll> b, r, k;
        for (int i = 0; i <= 7; i ++) if (T[i] == 'B') b.push_back(i);
        for (int i = 0; i <= 7; i ++) if (T[i] == 'K') k.push_back(i);
        for (int i = 0; i <= 7; i ++) if (T[i] == 'R') r.push_back(i);
        if ((b[1] - b[0]) % 2 == 0) continue;
        if (r[0] > k[0] || r[1] < k[0]) continue;
        s.insert(T);
    } while(next_permutation(T.begin(), T.end()));
    for (auto x: s) v.push_back(x);

    ios_base::sync_with_stdio(0); cin.tie(0);

    int test = 1; 
    // cin >> test;
    for (int _ = 1; _ <= test; _ ++) doTest(test);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3668kb

input:

GAME 1
2
5
0
1
1
8
END

output:

NRBBNQKR
RKBBNQRN
BBNNQRKR
BBRKNNRQ
BNNBRKRQ
RKRBBQNN

result:

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

Test #2:

score: -100
Time Limit Exceeded

input:

GAME 1
2
5
0
1
1
8
GAME 2
1
4
0
2
2
8
GAME 3
1
3
0
3
1
8
GAME 4
1
4
1
2
0
8
GAME 5
3
6
0
2
0
8
GAME 6
2
4
0
4
2
8
GAME 7
0
3
0
1
0
8
GAME 8
0
3
1
1
2
8
GAME 9
0
2
1
2
1

output:

NRBBNQKR
RKBBNQRN
BBNNQRKR
BBRKNNRQ
BNNBRKRQ
RKRBBQNN
NRBBNQKR
RKBBNQRN
BBNNQRKR
BBRKNNRQ
BBNRKNQR
RKRBBNQN
NRBBNQKR
RKBBNQRN
BBNNQRKR
BBRKNNRQ
BBNNRKRQ
RKRBBNNQ
NRBBNQKR
RKBBNQRN
BBNNQRKR
BBRKNNRQ
BBNNRKRQ
RKRBQNBN
NRBBNQKR
RKBBNQRN
BBNNQRKR
BBRKNNRQ
BBNNRKQR
RKRBNQBN
NRBBNQKR
RKBBNQRN
BBNNQRKR
BBR...

result: