QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345254 | #7179. Fischer's Chess Guessing Game | installb# | WA | 21ms | 3800kb | C++14 | 2.8kb | 2024-03-06 18:05:47 | 2024-03-06 18:05:47 |
Judging History
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(998244353);
void solve(){
vector <string> H; G = iG;
string lis[6];
for(int ti = 0;ti < 6;ti ++){
int anss = G.size();
if(G.size() == 1) break;
string cur;
for(int x = 0;x < G.size();x ++){
lis[ti] = G[x];
map <int,int> chk;
for(int i = 0;i < G.size();i ++){
int cnt = 0;
for(int k = 0;k < 8;k ++) if(G[i][k] == lis[ti][k]) cnt ++;
chk[cnt] ++;
}
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];
}
}
cout << cur << endl;
int x; cin >> x;
if(x == 8) return;
for(int i = 0;i < G.size();i ++){
int cnt = 0;
for(int k = 0;k < 8;k ++) if(G[i][k] == lis[ti][k]) cnt ++;
if(cnt == 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;
// 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;
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 21ms
memory: 3800kb
input:
GAME 1 1 1 1 3 0
output:
NRBBNKQR BNRNQBKR BBRNNKRQ QBRNBKNR NRBQNKRB
result:
wrong answer (i) illegal position "" (game 1, guess 6) (test case 1)