QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#345327#7179. Fischer's Chess Guessing GameinstallbWA 184ms3816kbC++142.8kb2024-03-06 19:37:582024-03-06 19:37:58

Judging History

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

  • [2024-03-06 19:37:58]
  • 评测
  • 测评结果:WA
  • 用时:184ms
  • 内存:3816kb
  • [2024-03-06 19:37:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 800005;

vector <string> G,iG;
map <string,int> mp; int tot = 0;

void init1(){
    string s = "BBKNNQRR";
    do{
        int pk; vector <int> pb,pr;
        for(int i = 0;i < 8;i ++){
            if(s[i] == 'B') pb.push_back(i);
            if(s[i] == 'R') pr.push_back(i);
            if(s[i] == 'K') pk = i;
        }
        if((pb[0] & 1) == (pb[1] & 1)) continue;
        if(!(pr[0] < pk && pk < pr[1])) continue;
        if(mp.find(s) != mp.end()) continue;
        mp[s] = tot ++;
        G.push_back(s);
    }while(next_permutation(s.begin(),s.end()));
}

mt19937 rnd(436598883);
string SS;

int calc(string x,string y){ int r = 0; for(int i = 0;i < 8;i ++) if(x[i] == y[i]) r ++; return r; }

void solve(){
    vector <string> H;
    G = iG;
    string lis[6];
    for(int ti = 0;ti < 6;ti ++){
        int anss = G.size() + 1;
        if(G.size() == 1) break;
        string cur;
		shuffle(G.begin(),G.end(),rnd);
		if(ti > 0){
			for(int x = 0;x < G.size();x ++){
				map <int,int> chk;
				for(int i = 0;i < G.size();i ++) chk[calc(G[i],G[x])] ++;
				int mx = 0;
				for(auto it = chk.begin();it != chk.end();it ++) mx = max(mx,it->second);
				if(mx < anss){
					anss = mx;
					cur = G[x];
				}
			}
		}
		else{
			cur = "NRBBNKQR";
		}
        cout << cur << endl;
        int x;
        cin >> x;
        // x = calc(cur,SS);
        // cout << x << ' ' << cur << ' ' << SS << ' ' << G.size() << endl;
        if(x == 8) return;
        for(int i = 0;i < G.size();i ++) if(calc(cur,G[i]) == x) H.push_back(G[i]);
        G.swap(H); H.clear();
        lis[ti] = cur;
        // cout << ti << ' ' << anss << '\n';
    }
    cout << G[0] << endl;
    int x;
    cin >> x;
    // x = calc(G[0],SS);
    // for(int i = 0;i < 6;i ++) cout << lis[i] << '\n';
}

// void countt(){
//     string lis[6];
//     for(int i = 0;i < 6;i ++) cin >> lis[i];
//             map <vector <int>,int> chk;
//             for(int i = 0;i < tot;i ++){
//                 vector <int> vec;
//                 for(int j = 0;j < 6;j ++){
//                     int cnt = 0;
//                     for(int k = 0;k < 8;k ++) if(G[i][k] == lis[j][k]) cnt ++;
//                     vec.push_back(cnt);
//                 }
//                 // cout << G[i] << " : "; for(auto u : vec) cout << u << ' '; cout << endl;
//                 chk[vec] = 1;
//             }
//     cout << chk.size() << '\n';
// }

int main(){
    ios::sync_with_stdio(false);
    init1(); iG = G;
    // for(auto s : G) cout << s << ' ';
    // cout << tot << endl;
    // solve2();
    // countt();
    string str;
    while(cin >> str){
        if(str == "END") break;
        int x; cin >> x;
        // cin >> SS;
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 3744kb

input:

GAME 1
1
2
2
8
END

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
RKRBBQNN

result:

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

Test #2:

score: 0
Accepted
time: 180ms
memory: 3748kb

input:

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

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
RKRBBQNN
NRBBNKQR
RBBNQNKR
RNNKBBQR
QRNNKBBR
RKRBBNQN
NRBBNKQR
BNRKQBNR
RNBQKRNB
BRNQKBRN
RKRBBNNQ
NRBBNKQR
BNRKQBNR
RNBQKRNB
RKRBQNBN
NRBBNKQR
RBBQKNNR
BRKBQRNN
NNRBKRBQ
RKRBNQBN
NRBBNKQR
RBBNKQNR
QRKNNRBB
RNKBBRQN
RKRBNNBQ
NRBBNKQR
RKNNRQBB
RNKNBBRQ
RNQKBRNB
RKRQBBNN
NRB...

result:

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

Test #3:

score: 0
Accepted
time: 183ms
memory: 3816kb

input:

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

output:

NRBBNKQR
RBBNKQNR
RKBNNBRQ
BRKNQBNR
RBKQNNBR
RKQBBNNR
NRBBNKQR
RBBNQNKR
RNNKBBQR
RKNBBQNR
NRBBNKQR
NRBQKBRN
RBNNBKQR
RBQNNKBR
RKNBBNQR
NRBBNKQR
NRBQKBRN
RBNNBKQR
RQKBNNBR
RKQBNNBR
NRBBNKQR
RBBNQNKR
BBRNNQKR
RKNBQNBR
NRBBNKQR
NRBQKBRN
RBNNBKQR
QNRBBKNR
RKNBNQBR
NRBBNKQR
BNRKQBNR
RQKNBBNR
RKQNBBNR
NRB...

result:

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

Test #4:

score: 0
Accepted
time: 179ms
memory: 3816kb

input:

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

output:

NRBBNKQR
BNRKQBNR
RNBQKRNB
RQNNBBKR
BRQNKBRN
QRKRBBNN
NRBBNKQR
NRBQKBRN
NBBRQKRN
NRKBBQRN
NRKRBBQN
NRBBNKQR
RBBNQNKR
QRKBBRNN
NRKRBBNQ
NRBBNKQR
BNRKQBNR
RQBNKRNB
NBRQKRBN
QRKRBNNB
NRBBNKQR
RBBNQNKR
QRKBBRNN
NRKRBBNQ
NRKRBQNB
NRBBNKQR
NRBQKBRN
BRKBNNRQ
BRQKNBNR
RBBNNKRQ
NRKRBNQB
NRBBNKQR
RBBNQNKR
QRK...

result:

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

Test #5:

score: 0
Accepted
time: 184ms
memory: 3812kb

input:

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

output:

NRBBNKQR
RKNNRQBB
RNNQKRBB
RQNKRBBN
NRBBNKQR
RKNNRQBB
QNRKRNBB
QNNRKRBB
RNQKRBBN
NRBBNKQR
RKNNRQBB
RKNQBRNB
RKRNQBBN
RNNKRBBQ
NRBBNKQR
RKNNRQBB
RKRNQNBB
RQNKRNBB
NRBBNKQR
RKNNRQBB
RBNKRNBQ
RBNNKRBQ
RNQKRNBB
NRBBNKQR
RKNNRQBB
RKNNRBBQ
RNNKRQBB
NRBBNKQR
BNRKQBNR
RKNQBBNR
RNBKRQNB
RBBKQRNN
NRBBNKQR
NRB...

result:

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

Test #6:

score: -100
Wrong Answer
time: 18ms
memory: 3704kb

input:

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

output:

NRBBNKQR
NRBQKBRN
QRBKNBRN
NRBBNKQR
NRBQKBRN
NRBKQBRN
NRBBNKQR
BRNBQKNR
NRBKNQRB
NRBKNBRQ
NRBBNKQR
NRBQKBRN
RNBBQKRN
NRQNBKRB
QRBKNNRB
NRBBNKQR
NRBQKBRN
NRNQBKRB
NRKBBQRN
NRBKQNRB
NRBBNKQR
RNBKNBQR
BBRNNKQR
NRBKNQRB
NRBBNKQR
BNRKQBNR
RNBQKRNB
NBRKBQRN
QRNKBBRN
NRBBNKQR
RNBNQBKR
QRNNBKRB
NRQNKRBB
BRK...

result:

wrong answer (i) too many guesses in game 10, pos = `