auto initfill = [&] { for (int i = 0; i < h; ++ i) { for (int j = 0; j < w; ++ j) campus[i][j] = '.'; campus[i][w] = '\0'; } };
auto paint = [&](int x, int y) { for (int i = x, ii = 0; i < h; ++ i, ++ ii) { if (ii >= 20) break; if (i < 0) continue; for (int j = y, jj = 0; j < w; ++ j, ++ jj) { if (jj >= 50) break; if (graph[ii][jj] == '.') continue; if (j < 0) continue; campus[i][j] = graph[ii][jj]; } } };
auto paint180 = [&](int x, int y) { for (int i = x, ii = 19; i < h; ++ i, -- ii) { if (ii < 0) break; if (i < 0) continue; for (int j = y, jj = 49; j < w; ++ j, -- jj) { if (jj < 0) break; if (graph[ii][jj] == '.') continue; if (j < 0) continue; campus[i][j] = graph[ii][jj]; } } };
cin >> n >> h >> w; initfill(); while (n --) { cin >> x >> y >> r; if (r) paint180(x,y); else paint(x,y); }
for (int i = 0; i < h; ++ i) cout << campus[i] << endl;
cin >> n >> m; memset(dis, 0x3f, sizeof dis); while (m --) { int u, v, w; cin >> u >> v >> w; dis[u][v] = dis[v][u] = w; } for (int i = 1; i <= n; ++ i) dis[i][i] = 0; floyd(); for (int i = 1; i <= n; ++ i) for (int j = i+1; j <= n; ++ j) { longs tmp = sum(i, j); ans = min(tmp, ans); } cout << ans << endl;
auto jump = [&] { int s = 1, t = 0; for (int i = 1; i < n; ++ i) { if (c[i] != c[i+1]) { a[i] = i+1; t = i; } else { if (s != t) vv.emplace_back(s, i); int j = i+1; while (c[++ j] == c[i]); for (int k = i; k < j; ++ k) a[k] = j; i = j - 1; s = t = j - 1; } } if (s != n) vv.emplace_back(s, n); a[n] = 0; };
while (t --) { vv.clear(); cin >> n >> l; for (int i = 1; i <= n; ++ i) cin >> c[i]; if (n == 1 || n < l) cout << 0 << endl; else { jump(); longs ans = 0; for (auto ii : vv) { if (ii.second - ii.first + 1 < l) continue; int lim = ii.second - l + 1, noko = 0; for (int xx = ii.first + l - 1; xx <= ii.second; ++ xx) { ++ mm[c[xx]]; ++ noko; } for (int xx = ii.first; xx <= lim; ++ xx) { ans += noko - mm[c[xx]]; -- noko; -- mm[c[xx + l - 1]]; } mm.clear(); } cout << ans << endl; } }