Advertisement
audreych

12932 - Drop the ball

Feb 20th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char arr[501][501];
  4. int main(){
  5.     int n, m;
  6.     scanf("%d %d", &n, &m);
  7.     for(int i = 1; i <= n; i++){
  8.         for(int j = 1; j <= m; j++){
  9.             scanf(" %c", &arr[i][j]);
  10.         }
  11.     }
  12.    
  13.     int Q;
  14.     scanf("%d", &Q);
  15.     while(Q--){
  16.         int pos;
  17.         int i;
  18.         scanf("%d", &pos);
  19.         for(i = 1; i <= n; i++){
  20.             if(arr[i][pos] == '\\'){
  21.                 if(arr[i][pos+1] == '\\'){
  22.                     pos = pos + 1;
  23.                     continue;
  24.                 } else if(arr[i][pos+1] == '/'){
  25.                     printf("Stuck QQ\n");
  26.                     break;
  27.                 } else {
  28.                     printf("Right!\n");
  29.                     break;
  30.                 }
  31.             } else if(arr[i][pos] == '/'){
  32.                 if(arr[i][pos-1] == '/'){
  33.                     pos = pos - 1;
  34.                     continue;
  35.                 } else if(arr[i][pos-1] == '\\'){
  36.                     printf("Stuck QQ\n");
  37.                     break;
  38.                 } else {
  39.                     printf("Left!\n");
  40.                     break;
  41.                 }
  42.             }
  43.         }
  44.         if( i == n + 1){
  45.             printf("Position: %d\n", pos);
  46.         }
  47.     }
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement