98732024-03-14 10:16:39antiStefan sakkmesteri ambícióicpp17Wrong answer 0/1003ms4676 KiB
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    ifstream cin("input0.txt");

    int T;
    cin >> T;
    char t[8][8];
    bool meg[T] = {false};
    pair<int, int> kir;
    for(int h=0; h<T; h++){
        for(int i=0; i<8; i++){
            for(int j=0; j<8; j++){
                cin >> t[i][j];
                if(t[i][j] == 'q'){
                    kir.first = i;
                    kir.second = j;
                }
            }
        }
        if      (t[kir.first - 2][kir.second - 1] == 'N') meg[h] = true;
        else if (t[kir.first - 2][kir.second + 1] == 'N') meg[h] = true;
        else if (t[kir.first - 1][kir.second + 2] == 'N') meg[h] = true;
        else if (t[kir.first + 1][kir.second + 2] == 'N') meg[h] = true;
        else if (t[kir.first + 2][kir.second + 1] == 'N') meg[h] = true;
        else if (t[kir.first + 2][kir.second - 1] == 'N') meg[h] = true;
        else if (t[kir.first + 1][kir.second - 2] == 'N') meg[h] = true;
        else if (t[kir.first - 1][kir.second - 2] == 'N') meg[h] = true;
        else if (t[kir.first + 1][kir.second - 1] == 'P') meg[h] = true;
        else if (t[kir.first + 1][kir.second + 1] == 'P') meg[h] = true;

        for(int i=kir.first-1; i>=0; i--){
            if(t[i][kir.second] != '.'){
                if(t[i][kir.second] == 'R' || t[i][kir.second] == 'Q'){  //felfele
                    meg[h] = true;
                }
            break;
            }
        }
        for(int i=kir.first+1; i<8; i++){
            if(t[i][kir.second] != '.'){
                if(t[i][kir.second] == 'R' || t[i][kir.second] == 'Q'){  //lefele
                    meg[h] = true;
                }
            break;
            }
        }
        for(int j=kir.second-1; j>=0; j--){
            if(t[kir.first][j] != '.'){
                if(t[kir.first][j] == 'R' || t[kir.first][j] == 'Q'){  //balra
                    meg[h] = true;
                }
            break;
            }
        }
        for(int j=kir.second+1; j<8; j++){
            if(t[kir.first][j] != '.'){
                if(t[kir.first][j] == 'R' || t[kir.first][j] == 'Q'){  //jobbra
                    meg[h] = true;
                }
            break;
            }
        }
        for(int i=1; i<=min(kir.first, kir.second); i++){
            if(t[kir.first-i][kir.second-i] != '.'){
                if(t[kir.first-i][kir.second-i] == 'B' || t[kir.first-i][kir.second-i] == 'Q'){  //balra fel
                    meg[h] = true;
                }
            break;
            }
        }
        for(int i=1; i<=min(7 - kir.first, 7 - kir.second); i++){
            if(t[kir.first+i][kir.second+i] != '.'){
                if(t[kir.first+i][kir.second+i] == 'B' || t[kir.first+i][kir.second+i] == 'Q'){  //jobbra le
                    meg[h] = true;
                }
            break;
            }
        }
        for(int i=1; i<=min(kir.first, 7 - kir.second); i++){
            if(t[kir.first-i][kir.second+i] != '.'){
                if(t[kir.first-i][kir.second+i] == 'B' || t[kir.first-i][kir.second+i] == 'Q'){  //jobbra fel
                    meg[h] = true;
                }
            break;
            }
        }
        for(int i=1; i<=min(7 - kir.first, kir.second); i++){
            if(t[kir.first+i][kir.second-i] != '.'){
                if(t[kir.first+i][kir.second-i] == 'B' || t[kir.first+i][kir.second-i] == 'Q'){  //balra le
                    meg[h] = true;
                }
            break;
            }
        }

    }
    for(int i=0; i<T; i++){
        if(meg[i]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1800 KiB
subtask20/11
2Wrong answer3ms2000 KiB
3Wrong answer3ms2248 KiB
4Wrong answer3ms2504 KiB
5Wrong answer3ms2632 KiB
subtask30/12
6Wrong answer3ms2892 KiB
7Wrong answer2ms2972 KiB
8Wrong answer2ms2868 KiB
9Wrong answer2ms2996 KiB
subtask40/15
10Wrong answer3ms3192 KiB
11Wrong answer3ms3452 KiB
12Wrong answer3ms3672 KiB
13Wrong answer3ms3660 KiB
subtask50/16
14Wrong answer3ms3560 KiB
15Wrong answer2ms3668 KiB
16Wrong answer2ms3560 KiB
17Wrong answer3ms3920 KiB
subtask60/46
18Wrong answer3ms4176 KiB
19Wrong answer3ms4276 KiB
20Wrong answer2ms4212 KiB
21Wrong answer2ms4208 KiB
22Wrong answer3ms4444 KiB
23Wrong answer2ms4532 KiB
24Wrong answer3ms4652 KiB
25Wrong answer2ms4676 KiB
26Wrong answer2ms4676 KiB