QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#175734#7179. Fischer's Chess Guessing Gameucup-team061AC ✓931ms3904kbC++202.4kb2023-09-10 22:11:142023-09-10 22:11:14

Judging History

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

  • [2023-09-10 22:11:14]
  • 评测
  • 测评结果:AC
  • 用时:931ms
  • 内存:3904kb
  • [2023-09-10 22:11:14]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
const int N = 2e5 + 10, M = 4e6 + 10;
vector<string> tot;
void init(){
    string s = "KQRRBBNN";
    sort(s.begin(), s.end());
    do{
       int r1 = -1, r2 = -1, k = -1, b1 = -1, b2 = -1;
       for(int i = 0; i < 8; i++){
            if(s[i] == 'R'){
                if(r1 == -1) r1 = i;
                else r2 = i;
            }
            else if(s[i] == 'K') k = i;
            else if(s[i] == 'B'){
                if(b1 == -1) b1 = i;
                else b2 = i;
            }
       }
       if(r1 < k && k < r2 && ((b1 + b2) % 2 == 1)) tot.eb(s);
    }while(next_permutation(s.begin(), s.end()));
}
string ans;
int query(string t){
    cout << t << '\n';
    int res = 0;
/*
    for(int i = 0; i < 8; i++){
        if(ans[i] == t[i]) res++;
    }
*/
    cin >> res;
    return res;
}
int cal(string s, string t){
    int sum = 0;
    for(int i = 0; i < 8; i++){
        if(s[i] == t[i]) sum++;
    }
    return sum;
}
int num;
    int T = 1;
void solve(){
    vector<string> v, tmp;
    for(string t : tot) v.eb(t);
    int cnt = 0, res = 0;
    while(v.size()){
        cnt++;
        int mn = INF, id = 0;
        for(int i = 0; i < v.size(); i++){
            int mx = 0, c[9] = {0};
            for(int j = 0; j < v.size(); j++){
                c[cal(v[i], v[j])]++;
            }
            for(int j = 0; j <= 8; j++){
                mx = max(mx, c[j]);
            }
            if(mx <= mn) mn = mx, id = i;
        }
        string s = v[id];
        if(T == 2 && cnt == 2 && res == 1) s = "BBRNQKNR";
        res = query(s);
        if(res == 8) break;
        tmp.clear();
        for(string t:v){
            if(cal(s, t) == res) tmp.eb(t);
        }
        swap(v, tmp);
    }
    if(cnt > 6){
        cout << num << " " << cnt << '\n';
        cout << ans << '\n';
        return;
    }
}
signed main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0), cout.tie(0);
    init();
    //ans = tot[51];
    //solve();
    //for(int i = 0; i < tot.size(); i++) ans = tot[i], ++num, solve();
    //return 0;
    string t;
    while(cin >> t){
        if(t == "END") break;
        cin >> T;
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 7ms
memory: 3600kb

input:

GAME 1
3
1
6
8
END

output:

RQKNBBRN
NRBKQBRN
RKQBBRNN
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 931ms
memory: 3724kb

input:

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

output:

RQKNBBRN
NRBKQBRN
RKQBBRNN
RKRBBQNN
RQKNBBRN
NRBKQBRN
RKQBBRNN
RKRBBNQN
RQKNBBRN
RNQKNBBR
BBRNNKRQ
QNBBRKRN
RKRBBNNQ
RQKNBBRN
RNQKNBBR
RQBBKNNR
RNBNKRQB
RKRBQNBN
RQKNBBRN
RNQKNBBR
QRBNNBKR
RBNKBNQR
RKRBNQBN
RQKNBBRN
RNBQKRNB
NNRBBKQR
RKNBQNBR
RKRBNNBQ
RQKNBBRN
RQBNKBNR
RQNKRBBN
RKRQBBNN
RQKNBBRN
RQK...

result:

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

Test #3:

score: 0
Accepted
time: 891ms
memory: 3672kb

input:

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

output:

RQKNBBRN
RNQKNBBR
QRBNNBKR
RBNKBNQR
RQNBKNBR
RKQBBNNR
RQKNBBRN
RNQKNBBR
RQBBKNNR
RNBQKNRB
RKNBBQNR
RQKNBBRN
RNQKNBBR
RQBBKNNR
RNBQKNRB
RKNBBNQR
RQKNBBRN
RNBQKRNB
NNRBBKQR
RKNBQNBR
RKQBNNBR
RQKNBBRN
RNBQKRNB
NNRBBKQR
RKNBQNBR
RQKNBBRN
RNBQKRNB
NNRBBKQR
RKNBQNBR
RKQBNNBR
RKNBNQBR
RQKNBBRN
RQBNKBNR
RQN...

result:

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

Test #4:

score: 0
Accepted
time: 909ms
memory: 3664kb

input:

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

output:

RQKNBBRN
RQBNKBNR
RNKQRBBN
RBKRBQNN
QRKRBBNN
RQKNBBRN
RQBNKBNR
RNKBBNRQ
NRQKBBRN
NRKRBBQN
RQKNBBRN
NRBKQBRN
NRKQBBNR
NRKRBBNQ
RQKNBBRN
RNQKNBBR
QBBRKNRN
BBRNKRQN
QRKRBNNB
RQKNBBRN
RNQKNBBR
QBBRKNRN
NRNBBKRQ
NRKRBQNB
RQKNBBRN
RNQKNBBR
QBBRKNRN
NRKRBNQB
RQKNBBRN
NRBKQBRN
NRKQBBNR
RQBKNBNR
QRKRNBBN
RQK...

result:

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

Test #5:

score: 0
Accepted
time: 910ms
memory: 3892kb

input:

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

output:

RQKNBBRN
RQBNKBNR
RQNKRBBN
RQKNBBRN
NRBKQBRN
NRKQBBNR
RKNRQBBN
RNQKRBBN
RQKNBBRN
RNQKNBBR
RNNQKBBR
RNNKRBBQ
RQKNBBRN
RNQKNBBR
QRBNNBKR
RNKQRNBB
RQNKRNBB
RQKNBBRN
RNBQKRNB
RNBBQNKR
RNQKRNBB
RQKNBBRN
RNBQKRNB
RNBBQNKR
BNQRKBNR
RNNKRQBB
RQKNBBRN
RNQKNBBR
RQBBKNNR
RNBNKRQB
RKBQNNRB
RBBKQRNN
RQKNBBRN
RNQ...

result:

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

Test #6:

score: 0
Accepted
time: 916ms
memory: 3616kb

input:

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

output:

RQKNBBRN
NRBKQBRN
NRBQKBRN
QRBKNBRN
RQKNBBRN
NRBKQBRN
RQKNBBRN
RNQKNBBR
QRBNNBKR
QRNKBBNR
NRBKNBRQ
RQKNBBRN
RNBQKRNB
BNRKQBNR
RKNRQNBB
QRBKNNRB
RQKNBBRN
RNBQKRNB
BNRKQBNR
NRBKQNRB
RQKNBBRN
RNBQKRNB
BNRKQBNR
RKNRQNBB
NBRNKRBQ
NRBKNQRB
RQKNBBRN
RQBNKBNR
RNKBBNRQ
NRQKBBRN
QRNKBBRN
RQKNBBRN
RQBNKBNR
RNK...

result:

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

Test #7:

score: 0
Accepted
time: 907ms
memory: 3728kb

input:

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

output:

RQKNBBRN
RNQKNBBR
BBRNNKRQ
RKBNRQNB
RKNBBRNQ
RBBQKRNN
RQKNBBRN
NRBKQBRN
QRNNBKRB
RNQKBBNR
RBBNKRQN
RQKNBBRN
RNQKNBBR
BBRNNKRQ
NQBRNKRB
RBBNKRNQ
RQKNBBRN
NRBKQBRN
RKQBBRNN
RKNRBBNQ
RBQNKRBN
RQKNBBRN
RNQKNBBR
RQBBKNNR
RKRNQNBB
RBNQKRBN
RQKNBBRN
RNQKNBBR
RQBBKNNR
RKRNQNBB
RKNBRQBN
RBNNKRBQ
RQKNBBRN
NRB...

result:

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

Test #8:

score: 0
Accepted
time: 912ms
memory: 3904kb

input:

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

output:

RQKNBBRN
BBQRNNKR
QRBBNKNR
NRBBKNQR
QRNBKNBR
RQKNBBRN
BBQRNNKR
NRBBQNKR
QNBBRNKR
NRQBKNBR
RQKNBBRN
BBQRNNKR
QRBKRNNB
NRNBQKBR
NRNBKQBR
RQKNBBRN
RNQKNBBR
QRBNNBKR
RBBNNQKR
QRNNKBBR
RQKNBBRN
RNQKNBBR
RNQBKRBN
NRQNKBBR
RQKNBBRN
RNBQKRNB
BNRKQBNR
NRBKQNRB
NRNQKBBR
RQKNBBRN
RNBQKRNB
QNBRKNRB
RKNQNRBB
BBR...

result:

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

Test #9:

score: 0
Accepted
time: 918ms
memory: 3600kb

input:

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

output:

RQKNBBRN
BBQRNNKR
QBRKNNBR
QBBRNKNR
QBBRKNNR
RQKNBBRN
BBQRNNKR
NRBBQNKR
NBNRQKBR
NBRQKNBR
NBBRKQNR
RQKNBBRN
BBQRNNKR
QBRKNNBR
NBBRNKQR
NBBRKNQR
RQKNBBRN
BBQRNNKR
QBRKNNBR
QBNRNKBR
QBNRKNBR
RQKNBBRN
BBQRNNKR
BBNRNKQR
NBQRKNBR
RQKNBBRN
BBQRNNKR
NRBBQNKR
NBRQNKBR
NBNRKQBR
RQKNBBRN
RNBQKRNB
QNBRKNRB
NRB...

result:

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

Test #10:

score: 0
Accepted
time: 917ms
memory: 3728kb

input:

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

output:

RQKNBBRN
BBQRNNKR
QBRKNNBR
QBBRNKNR
BBRQNKNR
RQKNBBRN
BBRNQKNR
RQKNBBRN
RNBQKRNB
BBRNQNKR
NBRNQKBR
BBRNNKQR
RQKNBBRN
RNBQKRNB
NNRBBKQR
NBRQBNKR
QRNBBKNR
BQRBNKNR
RQKNBBRN
BBQRNNKR
QRBBNKNR
NRBBKNQR
BNRBQKNR
RQKNBBRN
BBQRNNKR
NRBBQNKR
NBRQNKBR
NBNRKQBR
BNRBNKQR
RQKNBBRN
RNQKNBBR
BBRNNKRQ
QRBNNKRB
QBR...

result:

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

Test #11:

score: 0
Accepted
time: 908ms
memory: 3764kb

input:

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

output:

RQKNBBRN
NRBKQBRN
RQKBNNBR
RQNBBNKR
RQKNBBRN
RNQKNBBR
RNQBKRBN
RNQBBNKR
RQKNBBRN
RNQKNBBR
QRBNNBKR
RNBQNKRB
RNNBBQKR
RQKNBBRN
RQKNBRNB
RQNNBBKR
RQKNBBRN
RQBNKBNR
RNQNBBKR
RQKNBBRN
NRBKQBRN
RKQBBRNN
RKRNNBBQ
RNNQBBKR
RQKNBBRN
BBQRNNKR
QBBRNNKR
BBQRNKNR
BRQBNNKR
RQKNBBRN
BBQRNNKR
QBRKNNBR
BRQBNKNR
BRN...

result:

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

Extra Test:

score: 0
Extra Test Passed