第十三届JAVAB组决赛——5.窗口
import java.io.*;
import java.util.*;
public class Main{
public static BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
public static PrintWriter stdOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
public static final int N = 100010;
public static int n, m, k;
public static Windows[] a = new Windows[N]; //存放所有读入的窗口(PID)
public static List<Windows> q = new LinkedList<Windows>(); //存放所有读入的窗口
public static char[][] ans = new char[260][260]; //存放答案
public static void main(String[] args) throws IOException{
String[] sp = stdIn.readLine().split(" ");
n = Integer.parseInt(sp[0]); m = Integer.parseInt(sp[1]);
k = Integer.parseInt(stdIn.readLine());
while(k-- > 0) {
sp = stdIn.readLine().split(" ");
String op = sp[0];
if(op.equals("new")) {
int pid = Integer.parseInt(sp[1]); int i = Integer.parseInt(sp[2]);
int j = Integer.parseInt(sp[3]); int h = Integer.parseInt(sp[4]);
int w = Integer.parseInt(sp[5]);
a[pid] = new Windows(i, j, h, w);
q.add(0, a[pid]);
}else if(op.equals("move")){
int pid = Integer.parseInt(sp[1]); int vertical = Integer.parseInt(sp[2]);
int horizontal = Integer.parseInt(sp[3]);
q.remove(a[pid]);
a[pid].move(vertical, horizontal);
q.add(0, a[pid]);
}else if(op.equals("resize")) {
int pid = Integer.parseInt(sp[1]); int h = Integer.parseInt(sp[2]);
int w = Integer.parseInt(sp[3]);
q.remove(a[pid]);
a[pid].resize(h, w);
q.add(0, a[pid]);
}else if(op.equals("close")) {
int pid = Integer.parseInt(sp[1]);
q.remove(a[pid]);
}else {
int pid = Integer.parseInt(sp[1]);
q.remove(a[pid]);
q.add(0, a[pid]);
}
}
for(int i = 0; i < 260; i++)
for(int j = 0; j < 260; j++)
ans[i][j] = '.'; //初始化答案
//渲染答案
for(int index = q.size() - 1; index >= 0; index--) {
Windows temp = q.get(index);
int li = temp.i; int lj = temp.j;
int ri = temp.i + temp.h - 1; int rj = temp.j + temp.w - 1;
for(int i = li; i <= ri; i++) {
for(int j = lj; j <= rj; j++) {
if(i >= 0 && i < n && j >= 0 && j < m) {
if(i == li && j == lj || i == li && j == lj + temp.w - 1 || i == ri && j == rj || i == ri && j == rj - temp.w + 1)
ans[i][j] = '+';
else if(i == li || i == ri) ans[i][j] = '-';
else if(j == lj || j == rj) ans[i][j] = '|';
else ans[i][j] = ' ';
}
}
}
}
//打印输出答案
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
stdOut.print(ans[i][j]);
}
stdOut.println();
}
stdOut.flush();
}
}
class Windows{
int i; int j;
int h; int w;
public Windows(int i, int j, int h, int w) {
this.i = i; this.j = j; this.h = h; this.w = w;
}
public void move(int vertical, int horizontal) {
i += vertical;
j += horizontal;
}
public void resize(int h, int w) {
this.h = h;
this.w = w;
}
}