/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: displ.cpp * Author: cteam081 * * Created on 22. října 2016, 10:48 */ #include #include #include #include //#define DEBUG using namespace std; char transform(char c, int rotate, bool flipx, bool flipy) { static char rotator[256]; static char flipperx[256]; static char flippery[256]; static bool init; if (!init) { init = true; rotator['-' ] = '|'; rotator['/' ] = '\\'; rotator['<' ] = '^'; rotator['>' ] = 'v'; rotator['\\'] = '/'; rotator['^' ] = '>'; rotator['o' ] = 'o'; rotator['v' ] = '<'; rotator['x' ] = 'x'; rotator['|' ] = '-'; flippery['-' ] = '-'; flippery['/' ] = '\\'; flippery['<' ] = '>'; flippery['>' ] = '<'; flippery['\\'] = '/'; flippery['^' ] = '^'; flippery['o' ] = 'o'; flippery['v' ] = 'v'; flippery['x' ] = 'x'; flippery['|' ] = '|'; flipperx['-' ] = '-'; flipperx['/' ] = '\\'; flipperx['<' ] = '<'; flipperx['>' ] = '>'; flipperx['\\'] = '/'; flipperx['^' ] = 'v'; flipperx['o' ] = 'o'; flipperx['v' ] = '^'; flipperx['x' ] = 'x'; flipperx['|' ] = '|'; } #ifdef DEBUG return c; #endif while (rotate--) c = rotator[c]; if (flipx) c = flipperx[c]; if (flipy) c = flippery[c]; return c; } int main() { int lines; char map[101][101]; char buf[101][101]; string cmdline; while (cin >> lines) { int rotate = 0; bool flipx = false; bool flipy = false; for (int i = 0; i < lines; i++) { cin >> map[i]; } getline(cin, cmdline); if (cmdline == "") getline(cin, cmdline); for (char c : cmdline) { switch (c) { case '<': if ((flipx && flipy) || (!flipx && !flipy)) rotate += 3; else rotate++; break; case '>': if ((flipx && flipy) || (!flipx && !flipy)) rotate++; else rotate += 3; break; case '-': //if (rotate % 2 == 0) flipx = !flipx; //else // flipy = !flipy; break; case '|': //if (rotate % 2 == 0) flipy = !flipy; //else // flipx = !flipx; break; case '/': rotate++; if ((flipx && flipy) || (!flipx && !flipy)) flipx = !flipx; else flipy = !flipy; break; case '\\': rotate++; if ((flipx && flipy) || (!flipx && !flipy)) flipy = !flipy; else flipx = !flipx; break; } #ifdef DEBUG cout << "command [" << c << "]: " << rotate << (flipx ? 'x' : '.') << (flipy ? 'y' : '.') << endl; #endif } rotate %= 4; #ifdef DEBUG cout << "before: " << endl; for (int r = 0; r < lines; r++) { cout << map[r] << endl; } cout << "." << endl; #endif for (int i = 0; i < rotate; i++) { for (int r = 0; r < lines; r++) for (int c = 0; c < lines; c++) buf[r][c] = map[r][c]; for (int r = 0; r < lines; r++) for (int c = 0; c < lines; c++) map[r][c] = buf[lines - c - 1][r]; #ifdef DEBUG cout << "after rotation: " << endl; for (int r = 0; r < lines; r++) { cout << map[r] << endl; } cout << "." << endl; #endif } if (flipx) { for (int r = 0; r < lines / 2; r++) for (int c = 0; c < lines; c++) swap(map[r][c], map[lines - r - 1][c]); } if (flipy) { for (int r = 0; r < lines; r++) for (int c = 0; c < lines / 2; c++) swap(map[r][c], map[r][lines - c - 1]); } for (int r = 0; r < lines; r++) { for (int c = 0; c < lines; c++) map[r][c] = transform(map[r][c], rotate, flipx, flipy); cout << map[r] << endl; } } return 0; }