Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- long long n=5,m=5;
- int x[8]= {2,2,-2,-2,1,-1,1,-1};
- int y[8]= {1,-1,1,-1,2,2,-2,-2};
- vector<string> d(n);
- long long s=0;
- for(int i=0; i<n; i++)
- {
- cin>>d[i];
- }
- for(int i=0; i<n; i++)
- {
- for(int j=0; j<n; j++)
- {
- if(d[i][j]=='k')
- {
- s++;
- for(int p=0; p<8; p++)
- {
- if(i+x[p]>=0 && i+x[p]<5 && j+y[p]>0 && j+y[p]<5)
- {
- if(d[i+x[p]][j+y[p]]=='k')
- {
- cout<<"invalid"<<endl;
- return 0;
- }
- }
- }
- }
- }
- }
- if(s!=9)
- {
- cout<<"invalid"<<endl;
- return 0;
- }
- cout<<"valid"<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment