QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#195524#7179. Fischer's Chess Guessing Gameucup-team1430WA 1ms3640kbC++142.0kb2023-10-01 04:56:452023-10-01 04:56:46

Judging History

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

  • [2023-10-01 04:56:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2023-10-01 04:56:45]
  • 提交

answer

#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define endl '\n'
#define sws cin.tie(0)->sync_with_stdio(false);

const int N = 0;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;

bool is_valid(vector<char> s) {
    int n = s.size();
    bool ok = true;
    int bishop = -1, rook = -1;
    for (int i=0;i<n;i++) {
        auto c = s[i];
        if (c == 'B') {
            if (bishop == -1) bishop = i;
            else ok &= ((i - bishop) % 2 == 1);
        } else if (c == 'R') {
            if (rook == -1) rook = i;
            else rook = -1;
        } else if (c == 'K') {
            ok &= (rook != -1);
        }
    }

    return ok;
}


void solve() {

    vector<char> pos = {'K', 'Q', 'R', 'R', 'N', 'N', 'B', 'B'};
    sort(pos.begin(), pos.end());
    vector<vector<char>> positions;
    do {
        positions.push_back(pos);
    } while (next_permutation(pos.begin(), pos.end()));

    vector<vector<char>> positions2;
    for (auto p: positions) if (is_valid(p)) positions2.push_back(p);
    swap(positions, positions2);

    auto print = [&](vector<char> &x) {
        for (auto c: x) cout << c;
        cout << endl;
    };


    auto dist = [&](vector<char> &a, vector<char> &b) {
        int qnt = 0;
        int n = a.size();
        for (int i=0;i<n;i++) {
            if (a[i] != b[i]) qnt ++;
        }
        return qnt;
    };

    int it = 6;
    while (it --) {
        print(positions[0]);
        cout.flush();
        int x; cin >> x;

        if (x == 8) { return; }

        vector<vector<char>> positions2;

        for (auto p: positions) {
            if (dist(positions[0], p) == 8 - x) {
                positions2.push_back(p);
            }
        }
    }
}

int main() {
    #ifndef LOCAL
        sws;
    #endif

    string s; int t;
    while (cin >> s >> t) {
        solve();
    }


    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3640kb

input:

GAME 1
0
0
0
0
0
0

output:

BBNNQRKR
BBNNQRKR
BBNNQRKR
BBNNQRKR
BBNNQRKR
BBNNQRKR

result:

wrong answer (i) too many guesses in game 1, pos = 0Mdp