98752024-03-14 11:59:17antiStefan sakkmesteri ambícióicpp17Wrong answer 0/10010ms4208 KiB
#include <iostream>
#include <fstream>

using namespace std;

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

    int T;
    cin >> T;
    char t[10][10];
    for(int i=0; i<9; i++){
        t[0][i] = '.';
        t[9][i] = '.';
        t[i][0] = '.';
        t[i][9] = '.';
    }
    bool meg[T] = {false};
    pair<int, int> kir;
    for(int h=0; h<T; h++){
        for(int i=1; i<9; i++){
            for(int j=1; j<9; 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; cout << 1;}
        else if (t[kir.first - 2][kir.second + 1] == 'N'){ meg[h] = true; cout << 2;}
        else if (t[kir.first - 1][kir.second + 2] == 'N'){ meg[h] = true; cout << 3;}
        else if (t[kir.first + 1][kir.second + 2] == 'N'){ meg[h] = true; cout << 4;}
        else if (t[kir.first + 2][kir.second + 1] == 'N'){ meg[h] = true; cout << 5;}
        else if (t[kir.first + 2][kir.second - 1] == 'N'){ meg[h] = true; cout << 6;}
        else if (t[kir.first + 1][kir.second - 2] == 'N'){ meg[h] = true; cout << 7;}
        else if (t[kir.first - 1][kir.second - 2] == 'N'){ meg[h] = true; cout << 8;}
        else if (t[kir.first + 1][kir.second - 1] == 'P'){ meg[h] = true; cout << 9;}
        else if (t[kir.first + 1][kir.second + 1] == 'P'){ meg[h] = true; cout << 10;}

        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 answer3ms1772 KiB
subtask20/11
2Wrong answer3ms1996 KiB
3Wrong answer3ms2076 KiB
4Wrong answer3ms2216 KiB
5Wrong answer8ms2304 KiB
subtask30/12
6Wrong answer3ms2548 KiB
7Wrong answer3ms2600 KiB
8Wrong answer3ms2816 KiB
9Wrong answer10ms3028 KiB
subtask40/15
10Accepted3ms3112 KiB
11Accepted3ms3352 KiB
12Wrong answer3ms3468 KiB
13Wrong answer8ms3432 KiB
subtask50/16
14Accepted3ms3552 KiB
15Accepted3ms3580 KiB
16Wrong answer3ms3976 KiB
17Wrong answer8ms4044 KiB
subtask60/46
18Wrong answer3ms3880 KiB
19Wrong answer3ms3832 KiB
20Wrong answer3ms3828 KiB
21Wrong answer8ms3956 KiB
22Wrong answer8ms4080 KiB
23Wrong answer8ms4192 KiB
24Wrong answer8ms4196 KiB
25Wrong answer8ms4208 KiB
26Wrong answer8ms4160 KiB