fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(NULL);
  7.  
  8. int t;
  9. cin >> t;
  10.  
  11. while (t--) {
  12. bool flag = false;
  13. int n;
  14. cin >> n;
  15. int arr[n][n];
  16.  
  17. for (int i = 0; i < n; i++) {
  18. int count = 0;
  19. for (int j = 0; j < n; j++) {
  20. cin >> arr[i][j];
  21. if (arr[i][j] == 1) {
  22. count++;
  23. }
  24. }
  25. if (count == 1) {
  26. flag = true;
  27. cout << "TRIANGLE\n";
  28. break;
  29. }
  30. }
  31. if (!flag) {
  32. cout << "SQUARE"<< endl;
  33. }
  34. }
  35.  
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0.01s 5280KB
stdin
6
3
000
011
011
4
0000
0000
0100
1110
2
11
11
5
00111
00010
00000
00000
00000
10
0000000000
0000000000
0000000000
0000000000
0000000000
1111111110
0111111100
0011111000
0001110000
0000100000
3
111
111
111
stdout
SQUARE
SQUARE
SQUARE
SQUARE
SQUARE
SQUARE