QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#224190#7179. Fischer's Chess Guessing GameDanilo21RE 18ms10232kbC++173.3kb2023-10-23 00:26:592023-10-23 00:26:59

Judging History

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

  • [2023-10-23 00:26:59]
  • 评测
  • 测评结果:RE
  • 用时:18ms
  • 内存:10232kb
  • [2023-10-23 00:26:59]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

const ll LINF = 4e18;
const int mxN = 1e3+10, INF = 2e9;
int n, m;
vector<string> a;
const vector<char> chars = {'K', 'Q', 'R', 'R', 'B', 'B', 'N', 'N'};
vector<int> bucket[mxN][10];

int Ask(string s){

    cout << s << endl;
    ri(x);
    return x;
}

vector<char> Ers(vector<char> v, int i){

    vector<char> temp;
    for (int j = 0; j < v.size(); j++)
        if (j^i) temp.pb(v[j]);
    return temp;
}

void Gen(string s, vector<char> v){

    if (v.empty()){
        int k;
        vector<int> r, b;
        for (int i = 0; i < s.size(); i++){
            if (s[i] == 'K') k = i;
            if (s[i] == 'R') r.pb(i);
            if (s[i] == 'B') b.pb(i);
        }
        if (r[0] < k && k < r[1] && b[0] % 2 != b[1] % 2)
            a.pb(s);
        return;
    }
    for (int i = 0; i < v.size(); i++)
        Gen(s + v[i], Ers(v, i));
}

void Unique(){

    set<string> st;
    for (string s : a) st.insert(s);
    a.clear();
    for (string s : st) a.pb(s);
}

int Equal(string s, string t){

    int cnt = 0;
    for (int i = 0; i < 8; i++)
        if (s[i] == t[i]) cnt++;
    return cnt;
}

void Buckets(){

    for (int i = 0; i < a.size(); i++){
        for (int k = 0; k <= 8; k++)
            bucket[i][k].clear();
        for (int j = 0; j < a.size(); j++)
            bucket[i][Equal(a[i], a[j])].pb(j);
    }
}

void Game(){

    Gen("", chars);
    Unique();
    int x = 0;
    while (x < 8){
        Buckets();
        int b = -1, mx = mxN;
        for (int i = 0; i < a.size(); i++){
            int cur = 0;
            for (int j = 0; j <= 8; j++)
                smax(cur, (int)bucket[i][j].size());
            if (cur < mx){
                b = i;
                mx = cur;
            }
        }
        x = Ask(a[b]);
        vector<string> temp;
        for (int i : bucket[b][x])
            temp.pb(a[i]);
        a.clear();
        for (string s : temp) a.pb(s);
    }
    a.clear();
}

void Solve(){

    while (1){
        rs(text);
        if (text == "END") break;
        ri(n);
        Game();
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); cerr.tie(0);
    cout << setprecision(12) << fixed;
    cerr << setprecision(12) << fixed;
    cerr << "Started!" << endl;

    int t = 1;
    //cin >> t;
    while (t--)
        Solve();

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 18ms
memory: 10232kb

input:

GAME 1
1
2
2
1
2
8
END

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
QNRNBKRB
RKRBBQNN

result:

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

Test #2:

score: -100
Runtime Error

input:

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

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
QNRNBKRB
RKRBBQNN
NRBBNKQR
RBBNKQNR
QRKNNRBB
NBNRBKRQ
BQNBRNKR
RKRBBNQN
NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
RBKNBQNR
RKRBBNNQ
NRBBNKQR
BNRKQBNR
RNBQKRNB
BBNQRNKR
QBRKNRBN
RKRBQNBN
NRBBNKQR
RBBNKQNR
NBNQBRKR
BRKBRQNN
QRBKRNNB
RKRBNQBN
NRBBNKQR
RBBNKQNR
QRKNNRBB
NRK...

result: