/******************************************************* * Copyright (C) 2015 Haotian Wu * * This file is the solution to the question: * https://www.hackerrank.com/challenges/grid-challenge * * Redistribution and use in source and binary forms are permitted. *******************************************************/ #include #include #include #include #include #include #include #include #include #include using namespace std; // We sort all row arrays and see if all columns form a sorted array. int main() { int tt; scanf("%d",&tt); while (tt--) { int n; scanf("%d",&n); char str[101][101]; for (int i=0;istr[j+1][i]) flag = 0; printf("%s\n",flag?"YES":"NO"); } }