#include using namespace std; const int mx = 101; const int my = 103; int main(int argc, char *argv[]) { ios::sync_with_stdio(0); ifstream fin(argc > 0 ? argv[1] : "data.txt"); // NOTE: 14 and 101 for my dataset int start = argc >= 3 ? atoi(argv[2]) : 0; int step = argc >= 3 ? atoi(argv[3]) : 1; vector, pair>> robots; string line; while (getline(fin, line) && !line.empty()) { istringstream l(line); l.ignore(2); int px, py, vx, vy; l >> px; l.ignore(1); l >> py; l.ignore(3); l >> vx; l.ignore(1); l >> vy; if (vx < 0) { vx += mx; } if (vy < 0) { vy += my; } robots.push_back({{px, py}, {vx, vy}}); } char m[my][mx]; int n = start; for (auto &[p, v] : robots) { auto &[px, py] = p; auto &[vx, vy] = v; for (int i = 0; i < start; i++) { px = (px + vx) % mx; py = (py + vy) % my; } } for (;;) { memset(m, ' ', mx * my); for (auto &[p, v] : robots) { auto &[px, py] = p; auto &[vx, vy] = v; m[py][px] = '*'; for (int i = 0; i < step; i++) { px = (px + vx) % mx; py = (py + vy) % my; } } for (int y = 0; y < my; y++) { for (int x = 0; x < mx; x++) { cout << m[y][x]; } cout << '\n'; } cout << n << '\n'; n += step; cin.ignore(); } }