QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#345286#7179. Fischer's Chess Guessing Gameinstallb#WA 4ms4032kbC++142.0kb2024-03-06 19:03:202024-03-06 19:03:22

Judging History

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

  • [2024-03-06 19:03:22]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:4032kb
  • [2024-03-06 19:03:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
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);
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 < 5;ti ++){
        db anss = 0;
        if(G.size() == 1) break;
        string cur;
		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])] ++;
				db mx = 0, avg = 1.*G.size()/chk.size();
				for(auto it = chk.begin();it != chk.end();it ++){
					db val = 1.0 * it->second / G.size();
					mx += val * (it->second-avg) * (it->second-avg);
				}
				if(mx > anss){
					anss = mx;
					cur = G[x];
				}
			}
		}
		else{
			cur = "RBBNNQKR";
		}
        cout << cur << endl;
        int x;
        cin >> x;
        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 << G[0] << endl;
    int x;
    cin >> x;
}


int main(){
    ios::sync_with_stdio(false);
    init1();
    iG = G;
    string str;
    while(cin >> str){
        if(str == "END") break;
        int x; cin >> x;
        // cin >> SS;
        solve();
    }
    return 0;
}


詳細信息

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 4032kb

input:

GAME 1
2
2
2
1
1
0

output:

RBBNNQKR
BBRNKRNQ
BNRBQNKR
BRKQNBNR
RNKNQRBB
NBQRKNBR

result:

wrong answer (i) too many guesses in game 1, pos = @C>