QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#292679 | #7179. Fischer's Chess Guessing Game | AlphaMale06 | TL | 1280ms | 3752kb | C++14 | 2.4kb | 2023-12-28 11:01:51 | 2023-12-28 11:01:51 |
Judging History
answer
#include <bits/stdc++.h>
/*
Oce nas,
koji si na nebesima,
da se sveti ime Tvoje,
da dodje carstvo Tvoje,
da bude volja Tvoja,
i na zemlji, kao i na nebu.
Hleb nas nasusni daj nam danas,
i oprosti nam dugove nase,
kao sto i mi oprastamo duznicima svojim,
i ne uvedi nas u iskusenje,
no izbavi nas od zloga.
Jer je Tvoje Carstvo,
i sila, i slava,
u vekove vekova.
Amin.
*/
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) (x).begin(), (x).end()
set<string> st;
set<pair<int, string>> cur;
set<pair<int, string>> ncur;
bool checkvalid(string s){
int indb1, indb2, indk;
indb1=-1;
for(int i=0; i< 8; i++){
if(s[i]=='B'){
if(indb1==-1){
indb1=i;
}
else indb2=i;
}
if(s[i]=='K'){
indk=i;
}
}
if(indb1%2==indb2%2)return 0;
int cnt=0;
for(int i=0; i< indk; i++){
if(s[i]=='R')cnt++;
}
if(cnt==1)return 1;
return 0;
}
int inter(string a, string b){
int ans=0;
for(int i=0; i< 8; i++){
if(a[i]==b[i])ans++;
}
return ans;
}
void calcbest(){
for(auto it1= cur.begin(); it1!=cur.end(); it1++){
int cnt[9]={0};
for(auto it2=cur.begin(); it2!=cur.end(); it2++){
cnt[inter((*it1).S, (*it2).S)]++;
}
int mx=0;
for(int i=0; i< 9; i++)mx=max(mx, cnt[i]);
ncur.insert({mx, (*it1).S});
}
cur.clear();
for(auto it = ncur.begin(); it!=ncur.end(); it++){
cur.insert(*it);
}
ncur.clear();
}
void solve(){
for(auto it = st.begin(); it!=st.end(); it++){
cur.insert({0, *it});
}
int ans=0;
while(ans!=8){
calcbest();
string output= (*cur.begin()).S;
cout << output << endl;
cin >> ans;
for(auto it = cur.begin(); it!=cur.end(); it++){
if(inter(output, (*it).S)==ans){
ncur.insert(*it);
}
}
cur.clear();
for(auto it = ncur.begin(); it!=ncur.end(); it++){
cur.insert(*it);
}
ncur.clear();
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
string s="RRKNNQBB";
sort(all(s));
while(next_permutation(all(s))){
if(checkvalid(s))st.insert(s);
}
string partija;
cin >> partija;
while(partija!="END"){
int mrs;
cin >> mrs;
solve();
cin >> partija;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 15ms
memory: 3724kb
input:
GAME 1 1 2 2 1 2 8 END
output:
NRBBNKQR BNRKQBNR RNBQKRNB BRNQKBRN QNRNBKRB RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 6 (1 test case)
Test #2:
score: 0
Accepted
time: 1280ms
memory: 3724kb
input:
GAME 1 1 2 2 1 2 8 GAME 2 5 5 3 5 8 GAME 3 2 3 0 4 5 8 GAME 4 4 1 2 3 8 GAME 5 3 2 4 1 6 8 GAME 6 3 1 2 2 6 8 GAME 7 3 1 5 4 8 GAME 8 1 2 1 0 3 8 GAME 9 2 3 1 3 8 GAME 10 0 3 3 3 8 GAME 11 0 5 3 2 8 GAME 12 1 1 1 4 8 GAME 13 2 3 3 0 8 GAME 14 0 3 1 0 8 GAME 15 1 2 1 0 1 8 GAME 16 0 1 4 3 5 8 GAME 17...
output:
NRBBNKQR BNRKQBNR RNBQKRNB BRNQKBRN QNRNBKRB RKRBBQNN RQKBBNRN RKNBBQRN RBKNBQRN RKBBQNRN RKRBBNQN NRNBBKQR RBQNBNKR NBBRNQKR RKRNBBQN RKQBBRNN RKRBBNNQ RQKBBNRN RQKNBRNB BQNBRKRN RNBBKNRQ RKRBQNBN RQKBBNRN NRBBQKRN RKNBQNBR QRNBBNKR RKQBNRBN RKRBNQBN RQKBBNRN NRBBQKRN RKNRBBQN RBKNRQBN RKQBNNBR RKR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 1247ms
memory: 3752kb
input:
GAME 1 2 3 2 2 3 8 GAME 2 4 2 4 8 GAME 3 5 4 3 5 8 GAME 4 3 0 2 2 8 GAME 5 2 2 2 1 2 8 GAME 6 3 0 2 8 GAME 7 1 3 0 2 4 8 GAME 8 3 1 4 8 GAME 9 4 2 1 5 8 GAME 10 1 0 4 3 2 8 GAME 11 2 6 5 8 GAME 12 1 3 0 4 8 GAME 13 4 3 6 8 GAME 14 1 0 1 4 8 GAME 15 4 4 3 6 8 GAME 16 0 2 2 2 2 8 GAME 17 1 0 3 6 8 GAM...
output:
NRBBNKQR RBBNKQNR RKBNNBRQ BRKNQBNR RBKQNNBR RKQBBNNR NRNBBKQR BNRBNKQR NRBBKQNR RKNBBQNR NRNBBKQR BNNBRKQR QRNBNKBR RBNNBKQR RKNBBNQR NRBBNKQR NRBQKBRN RBNNBKQR BNRBQKNR RKQBNNBR NRBBNKQR RBBNKQNR NBNQBRKR BRNNKRQB NNQRKBBR RKNBQNBR NRNBBKQR NRKQBBRN BBNRQKNR RKNBNQBR NRBBNKQR BNRKQBNR BQRKNNRB QNN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: -100
Time Limit Exceeded
input:
GAME 1 1 2 1 0 8 GAME 2 3 3 4 3 8 GAME 3 2 1 2 8 GAME 4 2 2 0 1 6 8 GAME 5 2 2 3 0 8 GAME 6 4 1 6 8 GAME 7 2 0 5 5 8 GAME 8 3 5 3 8 GAME 9 2 2 1 3 1 8 GAME 10 2 0 3 3 8 GAME 11 2 0 4 1 5 8 GAME 12 3 2 3 2 8 GAME 13 2 2 0 8 GAME 14 4 1 4 2 8 GAME 15 2 1 2 4 8 GAME 16 2 1 4 6 8 GAME 17 4 1 5 3 8 GAME ...
output:
NRBBNKQR BNRKQBNR RNBQKRNB BBNQRNKR QRKRBBNN RQKBBNRN NRBBQKRN NRKBBQNR NRKBRNBQ NRKRBBQN NRBBNKQR RBBNKQNR QRKNNRBB NRKRBBNQ NRNBBKQR RBQNBNKR NBRKNQBR RKNQBBRN QRKNBRNB QRKRBNNB RQKBBNRN RKBBNQNR RNKNRQBB RKNQRBBN NRKRBQNB NRNBBKQR BNRBNKQR NRKNBRQB NRKRBNQB NRBBNKQR RBBNKQNR NRKQRBBN BRKQNBRN QRK...