#include using namespace std; using ll = long long; struct Train { int begin; int speed; int dir; int len; int motor; int end; }; struct Window { Train t; int window_end; Window(Train t, int wend) : t(t), window_end(wend) {}; void draw() { if (t.begin >= 0 && t.end <= window_end) { for (int i = 0; i <= window_end; ++i) { if (i == t.motor) { cout << '!'; continue; } if (i >= t.begin && i <= t.end) cout << '#'; else cout << '='; } } else if (t.begin >= 0 && t.end > window_end) { for (int i = 0; i <= window_end; ++i) { if (i == t.motor) { cout << '!'; continue; } if (i >= t.begin) cout << '#'; else cout << '='; } } else if (t.begin < 0) { for (int i = 0; i <= window_end; ++i) { if (i == t.motor) { cout << '!'; continue; } if (i <= t.end) cout << '#'; else cout << '='; } } cout << '\n'; } }; int main() { int N, M, T; cin >> N >> M >> T; vector windows; for (int i = 0; i < M; ++i) { int P, S; cin >> P >> S; char D; cin >> D; int L; cin >> L; Train t = {P, S, D, L, -1}; // calculate train position after moving if (t.dir == 'R') { t.begin += t.speed * T; t.motor = t.begin + t.len - 1; t.end = t.motor; } else { t.begin -= t.speed * T; t.motor = t.begin; t.end = t.begin + t.len - 1; } Window win(t, N - 1); windows.push_back(win); } for (auto win : windows) { win.draw(); } return 0; }