#include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; constexpr double EPS = 1e-9; int cells; void write_cell(char* view, ll position, char symbol) { if (position < 0 || position >= cells) { return; } view[position] = symbol; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int tracks, time; cin >> cells >> tracks >> time; char view[cells + 1]; for (int track = 0; track < tracks; track++) { view[cells] = '\0'; for (int i = 0; i < cells; ++i) { view[i] = '='; } ll position, speed; char direction; ll length; cin >> position >> speed >> direction >> length; int dir = direction == 'L' ? -1 : 1; ll headPosition = direction == 'L' ? position : position + length - 1; ll headUpdated = headPosition + speed * time * dir; write_cell(view, headUpdated, '!'); if (length <= 1) { cout << view << '\n'; continue; } ll firstBody = headUpdated - dir; ll lastBody = headUpdated - dir * (length - 1); if (firstBody > lastBody) { std::swap(firstBody, lastBody); } ll leftBound = max(0ll, firstBody); ll rightBound = min(static_cast(cells), lastBody); for (ll i = leftBound; i <= rightBound; ++i) { write_cell(view, i, '#'); } cout << view << '\n'; } return 0; }