97152024-03-02 17:26:22IgnácStefan sakkmesteri ambícióicpp17Compilation error

// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    vector<string> a(8);
    for(int fghjk=0;fghjk<t;fghjk++){

        for(int i=0;i<8;i++){
            cin>>a[i];
        }
        bool b=false;
        int bish, k;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                k=i;
                bish=j;
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                if(a[i][j]=='N'){
                    if(i-2>=0 && j-1>=0){
                        if(a[i-2][j-1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-2>=0 && j+1<=7){
                        if(a[i-2][j+1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+2<=7 && j-1>=0){
                        if(a[i+2][j-1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+2<=7 && j+1<=7){
                        if(a[i+2][j+1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-1>=0 && j-2>=0){
                        if(a[i-1][j-2]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-1>=0 && j+2<=7){
                        if(a[i-1][j+2]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+1<=7 && j-2>=0){
                        if(a[i+1][j-2]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+1<=7 && j+2<=7){
                        if(a[i+1][j+2]=='q'){
                            b=true;
                            break;
                        }
                    }
                }
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                if(a[i][j]=='B'){
                    k=i;
                    bish=j;
                    while(k>=0 && bish>=0){
                        k--;
                        bish--;
                        if(bish<0 || k<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    if(b){
                        break;
                    }
                    k=i;
                    bish=j;
                    while(k<=7 && bish>=0){
                        k++;
                        bish--;
                        if(bish<0 || k>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(k>=0 && bish<=7){
                        k--;
                        bish++;
                        if(bish>7 || k<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                    //      cout<<"I am right here\n";
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                    //  cout<<k<<' '<<bish<<'\n';
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(k<=7 && bish<=7){
                        k++;
                        bish++;
                        if(bish>7 || k>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                }
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                if(a[i][j]=='R'){
                    j=i;
                    bish=j;
                    while(k>=0){
                        k--;
                        if(k<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(k<=7){
                        k++;
                        if(k>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(bish<=7){
                        bish++;
                        if(bish>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(bish>=0){
                        bish--;
                        if(bish<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                }














                if(a[i][j]=='P'){
                    if(i-1>=0 && j-1>=0){
                        if(a[i-1][j-1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-1>=0 && j+1<=7){
                        if(a[i-1][j+1]=='q'){
                            b=true;
                            break;
                        }
                    }
                }

















                if(a[i][j]=='Q'){
                    k=i;
                    bish=j;
                    while(k>=0){
                        k--;
                        if(k<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(k<=7){
                        k++;
                        if(k>8){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(bish<=7){
                        bish++;
                        if(bish>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(bish>=0){
                        bish--;
                        if(bish<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    k=i, bish=j;
                    while(k>=0 && bish>=0){
                        k--;
                        bish--;
                        if(k<0 || bish<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    if(b){
                        break;
                    }
                    k=i;
                    bish=j;
                    while(k<=7 && bish>=0){
                        k++;
                        bish--;
                        if(k>7 || bish<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(k>=0 && bish<=7){
                        k--;
                        bish++;
                        if(k<0 || bish>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                    while(k<=7 && bish<=7){
                        k++;
                        bish++;
                        if(k>7 || bish>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    k=i;
                    bish=j;
                    if(b){
                        break;
                    }
                }
            }
            if(b){
                break;
            }
        }
        if(!b){
            cout<<"NO\n";
        }else{
            cout<<"YES\n";
        }
    }
}



    cin>>t;


// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin>>t;
    vector<string> a(8);
    for(int fghjk=0;fghjk<t;fghjk++){

        for(int i=0;i<8;i++){
            cin>>a[i];
        }
        bool b=false;
        int bish, k;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                k=i;
                bish=j;
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                if(a[i][j]=='N'){
                    if(i-2>=0 && j-1>=0){
                        if(a[i-2][j-1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-2>=0 && j+1<=7){
                        if(a[i-2][j+1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+2<=7 && j-1>=0){
                        if(a[i+2][j-1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+2<=7 && j+1<=7){
                        if(a[i+2][j+1]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-1>=0 && j-2>=0){
                        if(a[i-1][j-2]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i-1>=0 && j+2<=7){
                        if(a[i-1][j+2]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+1<=7 && j-2>=0){
                        if(a[i+1][j-2]=='q'){
                            b=true;
                            break;
                        }
                    }
                    if(i+1<=7 && j+2<=7){
                        if(a[i+1][j+2]=='q'){
                            b=true;
                            break;
                        }
                    }
                }
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                if(a[i][j]=='B'){
                    k=i;
                    bish=j;
                    while(k>=0 && bish>=0){
                        k--;
                        bish--;
                        if(bish<0 || k<0){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        
                    }
                    if(b){
                        break;
                    }
                    k=i;
                    bish=j;
                    while(k<=7 && bish>=0){
                        k++;
                        bish--;
                        if(bish<0 || k>7){
                            break;
                        }
                        if(a[k][bish]=='q'){
                            b=true;
                            break;
                        }
                        if(a[k][bish]!='.'){
                            break;
                        }
                        <
Compilation error
exit status 1
main.cpp:521:5: error: 'cin' does not name a type
  521 |     cin>>t;
      |     ^~~
main.cpp:529:5: error: redefinition of 'int main()'
  529 | int main() {
      |     ^~~~
main.cpp:7:5: note: 'int main()' previously defined here
    7 | int main() {
      |     ^~~~
main.cpp: In function 'int main()':
main.cpp:669:25: error: expected primary-expression before '<' token
  669 |                         <
      |                         ^
main.cpp:669:26: error: expected primary-expression at end of input
  669 |                         <
      |                          ^
main.cpp:669:26: error: expected '}' at end of input
main.cpp:656:43: note: to match this '{'
  656 |                     while(k<=7 && bish>=0){
      |                                           ^
main.cpp:669:26: error: expected '}' at end of input
  669 |                         <
      |                          ^
main.cpp:633:33: note: to match this '{'
  633 |                 if(a[i][j]=='B'){
      |                                ...