QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224182#7179. Fischer's Chess Guessing GameuroskTL 26ms8228kbC++143.1kb2023-10-23 00:21:252023-10-23 00:21:25

Judging History

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

  • [2023-10-23 00:21:25]
  • 评测
  • 测评结果:TL
  • 用时:26ms
  • 内存:8228kb
  • [2023-10-23 00:21:25]
  • 提交

answer

#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define eb emplace_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}
#define si(a) (ll)(a.size())
using namespace std;

#define maxn 1005
map<ll,char> mp;
ll g[maxn][maxn];
string kod[maxn];
ll sad = 0;
bool test = 0;
map<string,bool> was;
map<vector<ll>,ll> calc;
vector<ll> upiti;
ll F(ll x,ll y){
    string a = kod[x];
    string b = kod[y];
    ll ans = 0;
    for(ll i = 0;i<8;i++) ans+=(a[i]==b[i]);
    return ans;
}
void reshi(vector<ll> v){
    //dbg(si(v));
    if(si(v)==1){
        return;
    }
    ll xopt = -1,maxi = llinf;
    if(calc[upiti]) xopt = calc[upiti];
    else{
        for(ll x : v){
            vector<vector<ll> > cur(9);
            for(ll y : v){
                cur[g[x][y]].pb(y);
            }
            ll curmax = 0;
            for(vector<ll> s : cur) curmax = max(curmax,si(s));
            if(curmax<maxi){
                xopt = x;
            }
        }
        calc[upiti] = xopt;
    }
    upiti.pb(xopt);
    cout<<kod[xopt]<<endl;
    ll cnt = 0;
    if(!test) cin >> cnt;
    else cnt = F(sad,xopt);
    vector<vector<ll> > cur(9);
    for(ll y : v){
        cur[F(xopt,y)].pb(y);
    }
    reshi(cur[cnt]);
}
void tc(){
    upiti.clear();
    vector<ll> v;
    for(ll i = 0;i<960;i++) v.pb(i);
    reshi(v);
}
int main(){
	int t; t = 1;
	mp[0] = mp[1] = 'B';
	mp[2] = mp[3] = 'N';
	mp[4] = mp[5] = 'R';
	mp[6] = 'Q';
	mp[7] = 'K';
	vector<vector<ll> > v;
	v.pb({});
	for(ll i = 0;i<960;i++) v[0].pb(i);
	ll tsz = 0;
	vector<ll> p(8);
	iota(all(p),0);
	do{
        ll b1 = -1,b2 = -1;
        ll r1 = -1,r2 = -1;
        ll k = -1;
        string cur = "";
        for(ll i = 0;i<8;i++){
            if(mp[p[i]]=='B'){
                if(b1==-1) b1 = i;
                else b2 = i;
            }else if(mp[p[i]]=='R'){
                if(r1==-1) r1 = i;
                else r2 = i;
            }else if(mp[p[i]]=='K'){
                k = i;
            }
            cur+=mp[p[i]];
        }
        if(was[cur]) continue;
        was[cur] = 1;
        bool ok = 1;
        ok&=((k>=r1)&&(k<=r2));
        ok&=((b1&1)!=(b2&1));
        if(ok) kod[tsz++] = cur;
	}while(next_permutation(all(p)));
	for(ll i = 0;i<960;i++) for(ll j = 0;j<960;j++) g[i][j] = F(i,j);
	while(1){
        //here;
        string s; cin >> s;
        if(s=="END") return 0;
        cin >> t;
        if(test){
            string curs;
            cin >> curs;
            for(ll i = 0;i<960;i++) if(kod[i]==curs) sad = i;
        }
		tc();
	}
	return (0-0);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 26ms
memory: 8228kb

input:

GAME 1
0
4
8
END

output:

QRKRNNBB
RKQNBBRN
RKRBBQNN

result:

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

Test #2:

score: -100
Time Limit Exceeded

input:

GAME 1
0
4
8
GAME 2
1
4
6
4

output:

QRKRNNBB
RKQNBBRN
RKRBBQNN
QRKRNNBB
RKQNBBRN
RKRBBQNN
RKRNBQNB

result: