-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGrid Challenge.cpp
More file actions
44 lines (39 loc) · 928 Bytes
/
Grid Challenge.cpp
File metadata and controls
44 lines (39 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//Author: Bishal Sarang
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while(T--)
{
int N;
cin >> N;
char grid[N + 1][N + 1];
vector <string> vect(N);
for(int i = 0; i < N; i++)
{
cin >> vect[i];
sort(vect[i].begin(), vect[i].end());
}
// for(auto x: vect)
// cout << x << " ";
bool flag = true;
for(int i = 1; i < N; i++)
{
for(int j = 0; j < N; j++)
{
if(vect[i - 1][j] > vect[i][j])
{
cout << "NO\n";
flag = false;
break;
}
}
if(!flag)
break;
}
if(flag)
cout << "YES\n";
}
return 0;
}