QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#292749 | #7179. Fischer's Chess Guessing Game | AlphaMale06 | AC ✓ | 15ms | 7468kb | C++14 | 2.4kb | 2023-12-28 12:34:22 | 2023-12-28 12:34:23 |
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()
vector<string> v;
vector<pair<int, int>> cur;
vector<pair<int, int>> precalc;
vector<pair<int, int>> ncur;
int gas[960][960];
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(int i, int j){
int ans=0;
for(int k=0; k< 8; k++){
if(v[i][k]==v[j][k])ans++;
}
return ans;
}
void calcbest(){
for(int i=0; i<cur.size(); i++){
int cnt[9];
for(int i=0; i< 9; i++)cnt[i]=0;
for(int j=0; j<cur.size(); j++){
cnt[gas[cur[i].S][cur[j].S]]++;
}
int mx=0;
for(int i=0; i< 9; i++)mx=max(mx, cnt[i]);
cur[i].F=mx;
}
sort(all(cur));
}
void solve(){
cur=precalc;
int ans=0;
while(ans!=8){
int ind=0;
if(cur.size()==960){
ind=rand()%5;
ind++;
}
cout << v[cur[ind].S] << endl;
cin >> ans;
for(auto p : cur){
if(gas[cur[ind].S][p.S]==ans){
ncur.pb({0, p.S});
}
}
cur=ncur;
ncur.clear();
calcbest();
}
}
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))v.pb(s);
}
for(int i=0; i< 960; i++){
for(int j=0; j< 960; j++){
gas[i][j]=inter(i, j);
}
}
for(int i=0; i< 960; i++){
cur.pb({0, i});
}
calcbest();
precalc=cur;
string partija;
cin >> partija;
while(partija!="END"){
int mrs;
cin >> mrs;
solve();
cin >> partija;
cur.clear();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 6ms
memory: 7468kb
input:
GAME 1 2 2 2 1 1 8 END
output:
NRBBNQKR RBBNQKNR RKBRNNQB QBNRBNKR RNKQNBBR RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 6 (1 test case)
Test #2:
score: 0
Accepted
time: 11ms
memory: 7276kb
input:
GAME 1 2 2 2 1 1 8 GAME 2 5 5 3 5 8 GAME 3 2 3 0 6 8 GAME 4 1 0 2 4 8 GAME 5 3 1 2 0 8 GAME 6 1 0 3 2 4 8 GAME 7 3 1 5 4 8 GAME 8 5 5 3 5 8 GAME 9 1 1 2 5 8 GAME 10 3 0 2 5 8 GAME 11 3 0 1 5 8 GAME 12 3 0 2 4 8 GAME 13 0 2 3 8 GAME 14 1 1 4 1 5 8 GAME 15 1 4 5 3 8 GAME 16 2 3 3 1 8 GAME 17 0 2 3 4 8...
output:
NRBBNQKR RBBNQKNR RKBRNNQB QBNRBNKR RNKQNBBR RKRBBQNN RQKBBNRN RKNBBQRN RBKNBQRN RKBBQNRN RKRBBNQN RQKNBBRN RKBQNBNR BRQNNBKR RKNBBRNQ RKRBBNNQ NRNBBKQR BQNRKRNB QNRKNBBR RNKBRQBN RKRBQNBN NRBBNQKR NRBKQBRN BNRBQNKR NBQNBRKR RKRBNQBN NRNBBKQR BQNRKRNB QNRKNBBR NBRKRQBN RBKQNNBR RKRBNNBQ RQKBBNRN NRB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #3:
score: 0
Accepted
time: 14ms
memory: 7444kb
input:
GAME 1 2 3 2 4 3 8 GAME 2 3 1 4 8 GAME 3 2 3 1 1 8 GAME 4 2 4 2 3 8 GAME 5 2 3 4 2 8 GAME 6 3 0 2 8 GAME 7 2 4 1 2 6 8 GAME 8 3 1 4 8 GAME 9 2 4 3 4 8 GAME 10 1 0 2 2 8 GAME 11 2 6 5 8 GAME 12 3 2 4 4 8 GAME 13 1 2 0 4 5 8 GAME 14 0 0 2 3 8 GAME 15 0 1 5 8 GAME 16 4 2 2 3 8 GAME 17 0 3 2 1 8 GAME 18...
output:
NRBBNQKR RBBNQKNR BBNRQNKR BNQBRKNR BRQNKBNR RKQBBNNR RQKBBNRN NRBBQKRN RKNRBBQN RKNBBQNR RQKNBBRN RKBQNBNR BRQNNBKR RBBNKRNQ RKNBBNQR NRNBBKQR RBQNBNKR NBBRQNKR BRQNNBKR RKQBNNBR NRBBNQKR RBBNQKNR BBNRQNKR BNRNQBKR RKNBQNBR NRNBBKQR NRKQBBRN BBNRQKNR RKNBNQBR RQKBBNRN RKBBNQNR NQBBNRKR RBBKRQNN RKN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #4:
score: 0
Accepted
time: 10ms
memory: 7268kb
input:
GAME 1 1 2 0 8 GAME 2 3 3 4 3 8 GAME 3 3 3 6 8 GAME 4 2 2 0 1 6 8 GAME 5 3 2 2 8 GAME 6 4 1 6 8 GAME 7 2 1 4 5 4 8 GAME 8 3 5 3 8 GAME 9 4 1 3 2 8 GAME 10 2 1 3 0 8 GAME 11 1 1 1 2 8 GAME 12 1 1 0 5 8 GAME 13 2 0 3 2 8 GAME 14 1 2 3 0 4 8 GAME 15 2 1 2 8 GAME 16 2 1 4 6 8 GAME 17 2 1 1 3 1 8 GAME 18...
output:
NRBBNQKR RNKNQBBR BNRNKQRB QRKRBBNN RQKBBNRN NRBBQKRN NRKBBQNR NRKBRNBQ NRKRBBQN RQKNBBRN NRBKQBRN NRKQBBNR NRKRBBNQ NRNBBKQR RBQNBNKR NBRKNQBR RKNQBBRN QRKNBRNB QRKRBNNB NRBBNQKR NRBKQBRN BRKBNNRQ NRKRBQNB NRNBBKQR BNRBNKQR NRKNBRQB NRKRBNQB RQKBBNRN RKBBNQNR BRKNNBRQ BRKRQBNN NRKRBBNQ QRKRNBBN RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #5:
score: 0
Accepted
time: 15ms
memory: 7252kb
input:
GAME 1 0 1 1 4 5 8 GAME 2 2 1 1 4 2 8 GAME 3 2 2 3 3 3 8 GAME 4 1 3 2 3 1 8 GAME 5 0 1 4 2 2 8 GAME 6 1 2 2 2 2 8 GAME 7 2 3 0 8 GAME 8 2 3 1 4 5 8 GAME 9 2 3 1 1 8 GAME 10 3 1 3 8 GAME 11 3 2 0 2 1 8 GAME 12 2 2 4 4 8 GAME 13 0 2 5 8 GAME 14 0 1 2 8 GAME 15 1 2 0 0 8 GAME 16 2 4 4 1 8 GAME 17 0 0 5...
output:
NRBBNQKR BQRNKRNB RNKRBNQB QBRKRNBN RBNKQRBN RQNKRBBN RQKBBNRN RKBBNQNR BRKNNBRQ RBQNKRBN QRNBKRBN RNQKRBBN RQKNBBRN RKBQNBNR RBNQKRBN RKQBRNBN RBKRNNBQ RNNKRBBQ NRNBBKQR BQNRKRNB BQRKNBNR RNQKBRNB BNQRNKRB RQNKRNBB NRBBNQKR BQRNKRNB RNKRBNQB QNNRBKRB RBKNBNRQ RNQKRNBB NRNBBKQR BQNRKRNB BRQKNNRB BNR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #6:
score: 0
Accepted
time: 15ms
memory: 7224kb
input:
GAME 1 3 6 5 5 8 GAME 2 2 1 3 2 1 8 GAME 3 2 3 3 1 8 GAME 4 1 1 2 4 8 GAME 5 3 6 4 8 GAME 6 2 0 3 5 8 GAME 7 3 3 2 2 2 8 GAME 8 4 2 3 4 8 GAME 9 3 2 3 4 8 GAME 10 3 2 2 3 2 8 GAME 11 2 0 1 3 2 8 GAME 12 2 0 2 3 1 8 GAME 13 2 2 3 3 3 8 GAME 14 3 2 2 1 8 GAME 15 3 3 3 5 8 GAME 16 0 2 2 1 3 8 GAME 17 3...
output:
NRBBNQKR NRBKQBRN NRBKRBQN NRBQKBRN QRBKNBRN RQKBBNRN RKBBNQNR BRKNNBRQ BBRNKQRN BNNBRKRQ NRBKQBRN RQKNBBRN RKBQNBNR BRQNNBKR BQNRKBNR NRBKNBRQ NRNBBKQR BQNRKRNB BBRKRNQN QBBRNNKR QRBKNNRB NRBBNQKR NRBKQBRN NRBKRBQN NRBKQNRB NRNBBKQR RBQNBNKR BRNKQBRN NRBKQRNB NRBKNQRB RQKBBNRN NRBBQKRN NRKBBQNR NQR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #7:
score: 0
Accepted
time: 11ms
memory: 7212kb
input:
GAME 1 1 1 0 1 3 8 GAME 2 2 2 2 0 8 GAME 3 2 3 1 8 GAME 4 0 4 1 4 8 GAME 5 0 2 1 4 8 GAME 6 1 3 0 8 GAME 7 4 4 4 3 8 GAME 8 2 2 4 2 2 8 GAME 9 1 2 1 3 2 8 GAME 10 2 3 1 2 3 8 GAME 11 1 8 GAME 12 2 2 3 1 1 8 GAME 13 2 1 0 3 8 GAME 14 0 1 4 2 3 8 GAME 15 1 3 1 1 1 8 GAME 16 2 1 1 5 3 8 GAME 17 0 2 4 2...
output:
NRBBNQKR RNKNQBBR QRNNBKRB NBRKRNBQ BNRBKRQN RBBQKRNN RQKBBNRN RKBBNQNR RNKNRQBB BNQBRNKR RBBNKRQN RQKNBBRN RKBQNBNR BRQNNBKR RBBNKRNQ NRNBBKQR BBRNKQRN BQRKNBRN RBBNKNRQ RBQNKRBN NRBBNQKR BQRNKRNB BNNRQKRB RBNKBRNQ RBNQKRBN NRNBBKQR BQNRKRNB BQRKNBNR RBNNKRBQ RQKBBNRN RQKNBRNB QRKBBRNN RBKRBQNN RQB...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #8:
score: 0
Accepted
time: 13ms
memory: 7220kb
input:
GAME 1 3 1 3 3 2 8 GAME 2 2 2 1 4 8 GAME 3 0 1 1 2 8 GAME 4 3 2 2 4 3 8 GAME 5 3 3 2 1 8 GAME 6 4 1 2 6 8 GAME 7 1 2 2 2 0 8 GAME 8 2 0 3 8 GAME 9 0 3 1 6 8 GAME 10 3 2 1 8 GAME 11 1 3 4 8 GAME 12 0 1 6 8 GAME 13 0 4 3 4 8 GAME 14 1 6 4 8 GAME 15 0 6 5 8 GAME 16 1 1 1 0 8 GAME 17 1 2 0 2 8 GAME 18 0...
output:
NRBBNQKR NRBKQBRN BNRBQNKR NNQBRKBR NBQRBNKR QRNBKNBR RQKBBNRN RKBBNQNR RNKNRQBB BNRBKNQR NRQBKNBR RQKNBBRN BBQRNNKR BNRQKRNB NRBKRNQB NRNBKQBR NRNBBKQR NRKQBBRN RBNQBNKR BRNKQBNR QRNKBRNB QRNNKBBR NRBBNQKR NRBKQBRN BRNBKQRN NNBBRKRQ NRQNKBBR NRNBBKQR BNRBNKQR NRKNBRQB NRNKQBBR NRNQKBBR RQKBBNRN BNR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #9:
score: 0
Accepted
time: 10ms
memory: 7228kb
input:
GAME 1 2 4 2 3 2 8 GAME 2 0 4 5 2 8 GAME 3 0 4 2 2 8 GAME 4 2 3 3 4 8 GAME 5 2 2 2 4 4 8 GAME 6 3 1 4 2 8 GAME 7 0 3 4 2 8 GAME 8 2 4 2 5 8 GAME 9 4 3 1 2 8 GAME 10 0 3 3 4 8 GAME 11 2 2 3 1 8 GAME 12 1 2 3 2 8 GAME 13 1 0 1 8 GAME 14 1 1 2 4 8 GAME 15 2 5 3 8 GAME 16 4 3 2 3 8 GAME 17 3 4 3 5 8 GAM...
output:
NRBBNQKR RBBNQKNR BNRBQKNR NBBRQKRN NBQNRKBR QBBRKNNR RQKBBNRN BBNRQKNR NBBRNKQR BBRNNKQR NBBRKQNR RQKNBBRN BBQRNNKR BBRKNQNR BRNBQNKR NBBRKNQR NRNBBKQR RBQNBNKR NBBRNQKR NBRKQNBR QBNRKNBR NRBBNQKR RBBNQKNR RKBRNNQB QBNRBNKR NBRKBNQR NBQRKNBR NRNBBKQR NRKQBBRN NBBRQKNR RBQNBKNR NBNRKQBR RQKBBNRN BBN...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #10:
score: 0
Accepted
time: 15ms
memory: 7312kb
input:
GAME 1 2 4 5 8 GAME 2 0 6 4 8 GAME 3 1 0 5 4 8 GAME 4 3 0 4 5 8 GAME 5 2 4 8 GAME 6 4 8 GAME 7 1 1 2 2 1 8 GAME 8 1 2 3 1 8 GAME 9 2 4 6 4 8 GAME 10 0 3 0 6 8 GAME 11 0 3 1 5 8 GAME 12 1 0 5 2 8 GAME 13 4 5 2 5 8 GAME 14 2 1 0 2 1 8 GAME 15 3 1 4 2 3 8 GAME 16 1 2 0 5 5 8 GAME 17 4 5 3 8 GAME 18 1 2...
output:
NRBBNQKR RBBNQKNR BNRBQKNR BBRQNKNR RQKBBNRN BBNRQKNR BBNRKQNR BBRNQKNR RQKNBBRN RNBQKRNB BBRNQNKR BQRBNNKR BBRNNKQR NRNBBKQR NRKQBBRN BBNRQKNR BBRNNKQR BQRBNKNR NRBBNQKR RBBNQKNR BNRBQKNR NRNBBKQR BNRBNKQR RQKBBNRN BNRKRNQB BQNRKBNR RKBNNBQR NBBRKRQN QBRNBKNR RQKNBBRN RNBQKRNB BNRKQBNR BNNRQKRB NBR...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Test #11:
score: 0
Accepted
time: 4ms
memory: 7220kb
input:
GAME 1 3 0 3 2 8 GAME 2 4 2 1 5 8 GAME 3 2 2 2 3 3 8 GAME 4 3 2 5 3 8 GAME 5 2 3 2 3 3 8 GAME 6 3 3 2 2 4 8 GAME 7 2 3 3 4 8 GAME 8 0 4 2 8 GAME 9 4 5 2 8 GAME 10 0 2 4 3 8 GAME 11 1 1 2 4 2 8 GAME 12 2 2 1 4 4 8 GAME 13 3 1 2 4 3 8 GAME 14 5 4 2 8 GAME 15 8 GAME 16 0 1 1 2 8 GAME 17 3 4 5 2 8 GAME ...
output:
NRBBNQKR NRBKQBRN BBNNRQKR BNRBKQNR RQNBBNKR RQKBBNRN RQKNBRNB NRKQBBRN RKNBBNQR RNQBBNKR RQKNBBRN RKBQNBNR RBNQKRBN RKNRBNQB RNKRNQBB RNNBBQKR NRNBBKQR NRKQBBRN RBNQBNKR NBQRBNKR RQNNBBKR NRBBNQKR RBBNQKNR BBNRQNKR BNQBRKNR QNBRKBNR RNQNBBKR NRNBBKQR NRKQBBRN NRQNKBBR NNQRBKRB NBRQBNKR RNNQBBKR RQK...
result:
ok (c) correct after 96 tests, max moves 6 (96 test cases)
Extra Test:
score: 0
Extra Test Passed