#include #include #include #include #include int n; struct fx { char field[101][101]; }; fx f1, f2; fx* curr = &f1; char command[1000001]; char table[][7] = { "v^<>^v", "^v>v^<>", "><^v><", "oooooo", "xxxxxx", "--||--", "||--||", "\\\\\\\\//", "////\\\\", }; char apply(char chr, int c) { const char* chars = "<>^vox|-/\\"; if (!strchr(chars, chr)) printf("!!!!!%c\n",chr); int c_idx = strchr(chars, chr) - chars; return table[c_idx][c]; }; void exec(char cmd) { const char* commands = "<>-|\\/"; //printf("exec %c %p %d\n",cmd,strchr(commands, cmd), strchr(commands, cmd) - commands); int c = strchr(commands, cmd) - commands; fx* new_curr; if (curr == &f1) new_curr = &f2; else new_curr = &f1; for (int y = 0; y < n; y++) { for (int x = 0; x < n; x++) { char nw = '#';//printf("%d %d\n", x, y); switch (cmd) { case '<': nw = curr->field[x][n - y - 1]; break; case '>': nw = curr->field[n - x - 1][y]; break; case '-': nw = curr->field[n - y - 1][x]; break; case '|': nw = curr->field[y][n - x - 1]; break; case '\\': nw = curr->field[x][y]; break; case '/': nw = curr->field[n - x - 1][n - y - 1]; break; } new_curr->field[y][x] = apply(nw, c); } } curr = new_curr; } int main() { while (scanf("%d", &n) > 0) { for (int i = 0; i < n; i++) scanf("%s", curr->field[i]); fgetc(stdin); fgets(command, sizeof(command), stdin); for (int i = 0; command[i]; i++) if (command[i] > ' ') exec(command[i]); for (int i = 0; i < n; i++) printf("%s\n", curr->field[i]); } }