public static void Solve() { var(H, W) = Scanner.Scan <int, int>(); var A = new int[H, W]; for (var i = 0; i < H; i++) { var AA = Scanner.ScanEnumerable <int>().ToArray(); for (var j = 0; j < W; j++) { A[i, j] = AA[j]; } } var B = new int[W, H]; for (var i = 0; i < H; i++) { for (var j = 0; j < W; j++) { B[j, i] = A[i, j]; } } Printer.Print2D(B, " "); }
public static void Solve() { var N = Scanner.Scan <int>(); var G = new char[N][]; for (var i = 0; i < N; i++) { G[i] = new char[N]; Array.Fill(G[i], '.'); } for (var i = 0; i < N; i++) { G[i][(i * 3) % N] = '#'; G[i][(i * 3 + 1) % N] = '#'; G[i][(i * 3 + 2) % N] = '#'; } for (var i = 0; i < N; i++) { if ((G[i][0], G[i][N - 1]) == ('#', '#')) { (G[i][1], G[i][N - 2]) = (G[i][N - 2], G[i][1]); } } Printer.Print2D(G); }
public static void Solve() { var(N, Q) = Scanner.Scan <int, int>(); var G = new bool[N, N]; while (Q-- > 0) { var query = Scanner.ScanEnumerable <int>().ToArray(); var a = query[1] - 1; if (query[0] == 1) { var b = query[2] - 1; G[a, b] = true; } else if (query[0] == 2) { for (var i = 0; i < N; i++) { if (i != a && G[i, a]) { G[a, i] = true; } } } else if (query[0] == 3) { var tmp = new bool[N]; for (var i = 0; i < N; i++) { if (!G[a, i]) { continue; } for (var j = 0; j < N; j++) { if (j == a) { continue; } if (G[i, j]) { tmp[j] = true; } } } for (var i = 0; i < N; i++) { if (tmp[i]) { G[a, i] = true; } } } } Printer.Print2D(G, x => x ? 'Y' : 'N'); }
public static void Solve() { var(H, W, A, B) = Scanner.Scan <int, int, int, int>(); var G = new int[H, W]; for (var i = 0; i < H; i++) { for (var j = 0; j < W; j++) { G[i, j] = (i < B) ^ (j < A) ? 1 : 0; } } Printer.Print2D(G); }
public static void Solve() { var N = Scanner.Scan <int>(); var G = new int[N, N]; var curr = 1; for (var k = 0; k < 2; k++) { for (var i = k; i < N; i += 2) { for (var j = 0; j < N; j++) { G[i, j] = curr++; } } } Printer.Print2D(G, " "); }
public static void Solve() { var N = Scanner.Scan <int>(); var(H, W) = (N, N * 2 - 1); var S = new char[H][]; for (var i = 0; i < H; i++) { S[i] = Scanner.Scan <string>().ToCharArray(); } for (var i = H - 2; i >= 0; i--) { for (var j = 0; j < W; j++) { if (S[i][j] != '#') { continue; } if (j - 1 >= 0 && S[i + 1][j - 1] == 'X') { S[i][j] = 'X'; } if (S[i + 1][j] == 'X') { S[i][j] = 'X'; } if (j + 1 < W && S[i + 1][j + 1] == 'X') { S[i][j] = 'X'; } } } Printer.Print2D(S); }
public static void Solve() { var(H, W, K) = Scanner.Scan <int, int, int>(); var S = new string[H]; var answer = new int[H, W]; var count = 1; for (var i = 0; i < H; i++) { S[i] = Scanner.Scan <string>(); for (var j = 0; j < W; j++) { if (S[i][j] == '#') { answer[i, j] = count++; } } } for (var h = 0; h < H; h++) { var k = 0; for (var w = 0; w < W; w++) { if (answer[h, w] == 0) { answer[h, w] = k; } else { k = answer[h, w]; } } for (var j = W - 1; j >= 0; j--) { if (answer[h, j] == 0) { answer[h, j] = k; } else { k = answer[h, j]; } } } for (var w = 0; w < W; w++) { var k = 0; for (var h = 0; h < H; h++) { if (answer[h, w] == 0) { answer[h, w] = k; } else { k = answer[h, w]; } } for (var h = H - 1; h >= 0; h--) { if (answer[h, w] == 0) { answer[h, w] = k; } else { k = answer[h, w]; } } } Printer.Print2D(answer, " "); }