#include <assert.h> #include <ctype.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> /*char* readline(); char* ltrim(char*); char* rtrim(char*); char** split_string(char*); // Complete the solve function below. /* * To return the string from the function, you should either do static allocation or dynamic allocation * * For example, * char* return_string_using_static_allocation() { * static char s[] = "static allocation of string"; * * return s; * } * * char* return_string_using_dynamic_allocation() { * char* s = malloc(100 * sizeof(char)); * * s = "dynamic allocation of string"; * * return s; * } * char* solve(int board_rows, int board_columns, int** board) { } int main() { FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w"); char* t_endptr; char* t_str = ltrim(rtrim(readline())); int t = strtol(t_str, &t_endptr, 10); if (t_endptr == t_str || *t_endptr != '\0') { exit(EXIT_FAILURE); } for (int t_itr = 0; t_itr < t; t_itr++) { char* n_endptr; char* n_str = ltrim(rtrim(readline())); int n = strtol(n_str, &n_endptr, 10); if (n_endptr == n_str || *n_endptr != '\0') { exit(EXIT_FAILURE); } int** board = malloc(n * sizeof(int*)); for (int i = 0; i < n; i++) { *(board + i) = malloc(n * (sizeof(int))); char** board_item_temp = split_string(rtrim(readline())); for (int j = 0; j < n; j++) { char* board_item_endptr; char* board_item_str = *(board_item_temp + j); int board_item = strtol(board_item_str, &board_item_endptr, 10); if (board_item_endptr == board_item_str || *board_item_endptr != '\0') { exit(EXIT_FAILURE); } *(*(board + i) + j) = board_item; } } int board_rows = n; int board_columns = n; char* result = solve(board_rows, board_columns, board); fprintf(fptr, "%s\n", result); } fclose(fptr); return 0; } char* readline() { size_t alloc_length = 1024; size_t data_length = 0; char* data = malloc(alloc_length); while (true) { char* cursor = data + data_length; char* line = fgets(cursor, alloc_length - data_length, stdin); if (!line) { break; } data_length += strlen(cursor); if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; } alloc_length <<= 1; data = realloc(data, alloc_length); if (!data) { data = '\0'; break; } } if (data[data_length - 1] == '\n') { data[data_length - 1] = '\0'; data = realloc(data, data_length); if (!data) { data = '\0'; } } else { data = realloc(data, data_length + 1); if (!data) { data = '\0'; } else { data[data_length] = '\0'; } } return data; } char* ltrim(char* str) { if (!str) { return '\0'; } if (!*str) { return str; } while (*str != '\0' && isspace(*str)) { str++; } return str; } char* rtrim(char* str) { if (!str) { return '\0'; } if (!*str) { return str; } char* end = str + strlen(str) - 1; while (end >= str && isspace(*end)) { end--; } *(end + 1) = '\0'; return str; } char** split_string(char* str) { char** splits = NULL; char* token = strtok(str, " "); int spaces = 0; while (token) { splits = realloc(splits, sizeof(char*) * ++spaces); if (!splits) { return splits; } splits[spaces - 1] = token; token = strtok(NULL, " "); } return splits; } */ int main() { int t,n,i,j,a[100][100]; scanf("%d",&t); for(i=0;i<t;i++) { scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<n;j++) { // int a[n][n]; scanf("%d",&a[i][j]); } } } for(i=0;i<n;i++) { for(j=0;j<n;j++) { //if((i==j)||(i!=j)==1) int k; k=i!=j; if(k==1) { printf("Yes"); break; } else printf("No \n"); break; } } return 0; }