QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#484910 | #7179. Fischer's Chess Guessing Game | Pedro_Sim | TL | 4ms | 3744kb | C++20 | 2.6kb | 2024-07-20 05:48:51 | 2024-07-20 05:48:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rp(i,a,b) for(int i=a;i<b;i++)
vector<string> resp;
bool veri(string &t){
int te = -1;
rp(i, 0, 8){
if(te >= 0 && t[i] == 'B' && (i%2) == (te%2)) return false;
else if(t[i] == 'B') te = i;
}
rp(i, 0, 8){
if(t[i] == 'K'){
bool flag1 = true, flag2 = true;
rp(j, 0, i) if(t[j] == 'R') flag1 = false;
rp(j, i, 8) if(t[j] == 'R') flag2 = false;
if(flag1 || flag2) return false;
break;
}
}
return true;
}
void solvetask(){
int n;
cin >> n;
vector<string> temp = resp;
//string compa = "BBNQRKNR";
int atual = 0;
string at;
for(int i = 0; i < temp.size(); i++){
int t=0;
for(int j = 0; j < temp.size(); j++){
int comp = 0;
for(int k = 0; k < 8; k++) if(temp[i][k] == temp[j][k]) comp++;
if(comp == 2) t++;
}
t = temp.size()-t;
if(t > atual){
t = atual;
at = temp[i];
}
}
for(int a = 0; a < 10; a++){
cout << at << endl;
fflush (stdout);
int iguais=0;
cin >> iguais;
//for(int j = 0; j < 8; j++) if(compa[j] == at[j]) iguais++;
if(iguais == 8) break;
vector<string> nova;
for(int j = 0; j < temp.size(); j++){
int comp = 0;
if(at == temp[j]) continue;
for(int k = 0; k < 8; k++) if(at[k] == temp[j][k]) comp++;
if(comp == iguais) nova.push_back(temp[j]);
}
temp = nova;
int atual = 0;
for(int i = 0; i < temp.size(); i++){
int t=0;
for(int j = 0; j < temp.size(); j++){
int comp = 0;
for(int k = 0; k < 8; k++) if(temp[i][k] == temp[j][k]) comp++;
if(comp == iguais) t++;
}
//cout << t << " " << at << " " << temp.size() << "\n";
t = temp.size()-t;
if(t > atual){
t = atual;
at = temp[i];
}
}
}
}
void pre_cal(){
string temp = "BBQKNNRR";
sort(temp.begin(), temp.end());
while(next_permutation(temp.begin(), temp.end())){
if(veri(temp))resp.push_back(temp);
else continue;
}
}
int main(){
cin.tie(0)->sync_with_stdio(0);
string t;
pre_cal();
while(true){
cin >> t;
if(t == "END") return 0;
solvetask();
}
}
详细
Test #1:
score: 100
Accepted
time: 4ms
memory: 3744kb
input:
GAME 1 1 3 5 8 END
output:
RQNNKRBB RNQKBBRN RNKBBQNR RKRBBQNN
result:
ok (c) correct after 1 tests, max moves 4 (1 test case)
Test #2:
score: -100
Time Limit Exceeded
input:
GAME 1 1 3 5 8 GAME 2 1 3 3 1 8 GAME 3 1 2 3 8 GAME 4 2 2 3 2 3 8 GAME 5 2 2 3 3 2 8 GAME 6 2 1 4 2 8 GAME 7 1 4 2 3 8 GAME 8 2 4 3 2 8 GAME 9 2 4 2 4 8 GAME 10 2 3 1 2 8 GAME 11 3 2 1 3 8 GAME 12 3 2 2 3 2 8 GAME 13 2 3 3 3 8 GAME 14 3 3 1 3 8 GAME 15 3 2 3 2 8 GAME 16 3 1 3 4 8 GAME 17 4 2 4 2 4 8...
output:
RQNNKRBB RNQKBBRN RNKBBQNR RKRBBQNN RQNNKRBB RNQKBBRN RNKBBQNR RNBQNBKR RKRBBNQN RQNNKRBB RNQKBBRN RNBBQNKR RKRBBNNQ RQNNKRBB RQKRBBNN RQBBNNKR RNQKNBBR RNBBKQRN RKRBQNBN RQNNKRBB RQKRBBNN RQBBNNKR RNQKNBBR RNNBBKQR RKRBNQBN RQNNKRBB RQKRBBNN RNQBNKBR RNBQNKRB RKRBNNBQ RQNNKRBB RNQKBBRN RNQBBNKR RNB...