1 solutions

  • 0
    @ 2023-2-8 19:57:00
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int i,j,n,m,t1,t2,t1i,t1j,t2i,t2j,a[205][205];
    	cin >> n >> m;
    	for(i = 1; i <= n; i++){
    		for(j = 1; j <= m; j++){
    			cin >> a[i][j];
    		}
    	}
    	cin >> t1 >> t2;
    	for(i = 1; i <= n; i++){
    		for(j = 1; j <= m; j++){
    			if(a[i][j] == t1){
    				t1i = i;
    				t1j = j;
    			}
    			if(a[i][j] == t2){
    				t2i = i;
    				t2j = j;
    			}
    		}
    	}
    	if((t1i-t2i == -1 || t1i-t2i == 1)&&(t1j-t2j == 0)||(t1j-t2j == -1||t1j-t2j == 1)&&(t1i-t2i == 0)){
    		cout << "Y" << endl;
    	}else{
    		cout << "N" << endl;
    	}
    	return 0;
    }
    
    
    • 1

    Information

    ID
    1337
    Time
    1000ms
    Memory
    64MiB
    Difficulty
    10
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By