QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468749#7179. Fischer's Chess Guessing Gameembusca#TL 0ms0kbC++201.2kb2024-07-09 00:05:552024-07-09 00:05:55

Judging History

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

  • [2024-07-09 00:05:55]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-07-09 00:05:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rp(i,a,b)        for(int i=a;i<b;i++)

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;
    string temp = "KQRRBBNN";
    sort(temp.begin(), temp.end());
    while(true){
        if(veri(temp)) cout << temp << endl;
        else{
            next_permutation(temp.begin(), temp.end());
            continue;
        }
        int t;
        cin >> t;
        if(t == 8) return;
        next_permutation(temp.begin(), temp.end());
    }
}

int main(){
    cin.tie(0)->sync_with_stdio(0);
    fflush (stdout);
    string t;
    while(true){
        cin >> t;
        if(t == "END") return 0;
        solvetask();
    } 
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

GAME 1
0
0
0
1
0
1

output:

BBNNQRKR
BBNNRKQR
BBNNRKRQ
BBNNRQKR
BBNQNRKR
BBNQRKNR
BBNQRKRN

result: