QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#224141 | #7179. Fischer's Chess Guessing Game | urosk | ML | 26ms | 4072kb | C++14 | 2.9kb | 2023-10-23 00:05:12 | 2023-10-23 00:05:12 |
Judging History
answer
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#define ld double
#define ll long long
#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;
string kod[maxn];
ll sad = 0;
bool test = 0;
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){
cout<<kod[v[0]]<<endl;
return;
}
ll xopt = -1,maxi = llinf;
for(ll x : v){
vector<vector<ll> > cur(9);
for(ll y : v){
cur[F(x,y)].pb(y);
}
ll curmax = 0;
for(vector<ll> s : cur) curmax = max(curmax,si(s));
if(curmax<maxi){
xopt = x;
}
}
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(){
vector<ll> v;
for(ll i = 0;i<960;i++) v.pb(i);
reshi(v);
}
map<string,bool> was;
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)));
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);
}
詳細信息
Test #1:
score: 100
Accepted
time: 26ms
memory: 4072kb
input:
GAME 1 0 4 8 END
output:
QRKRNNBB RKQNBBRN RKRBBQNN RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 3 (1 test case)
Test #2:
score: -100
Memory Limit Exceeded
input:
GAME 1 0 4 8 GAME 2 6 1 1
output:
QRKRNNBB RKQNBBRN RKRBBQNN RKRBBQNN QRKRNNBB QRKRNBBN