T3000

Untitled

Mar 29th, 2022
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. long long n=5,m=5;
  9. int x[8]= {2,2,-2,-2,1,-1,1,-1};
  10. int y[8]= {1,-1,1,-1,2,2,-2,-2};
  11. vector<string> d(n);
  12. long long s=0;
  13. for(int i=0; i<n; i++)
  14. {
  15. cin>>d[i];
  16.  
  17. }
  18.  
  19. for(int i=0; i<n; i++)
  20. {
  21. for(int j=0; j<n; j++)
  22. {
  23. if(d[i][j]=='k')
  24. {
  25. s++;
  26. for(int p=0; p<8; p++)
  27. {
  28. if(i+x[p]>=0 && i+x[p]<5 && j+y[p]>0 && j+y[p]<5)
  29. {
  30. if(d[i+x[p]][j+y[p]]=='k')
  31. {
  32. cout<<"invalid"<<endl;
  33. return 0;
  34. }
  35. }
  36. }
  37.  
  38. }
  39. }
  40. }
  41. if(s!=9)
  42. {
  43. cout<<"invalid"<<endl;
  44. return 0;
  45. }
  46. cout<<"valid"<<endl;
  47.  
  48.  
  49.  
  50.  
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment