Submission #381567

#TimeUsernameProblemLanguageResultExecution timeMemory
381567AraragiPaint (COI20_paint)C++17
8 / 100
3078 ms3436 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("00") typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> pii; ll time() {return chrono::system_clock().now().time_since_epoch().count();} mt19937 rnd(time()); const int inf = 1e9; const ll inf64 = 1e18; #define ft first #define fin(x) ifstream cin("x.in"); #define fout(x) ofstream cout("x.out"); #define sd second #define pb push_back #define sz(x) (int)x.size() int steps[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int grid[10001][10001]; bool bad[10001][10001]; int n, m; void dfs(int x, int y, int who, int to) { if (bad[x][y] || x < 0 || x >= n || y >= m || y < 0) return; grid[x][y] = to; bad[x][y] = true; for (int i = 0; i < 4; i++) { int cx = x + steps[i][0]; int cy = y + steps[i][1]; if (cx < 0 || cy < 0 || cx >= n || cy >= m || bad[cx][cy]) continue; if (grid[cx][cy] == who) dfs(cx, cy, who, to); } } void solve() { cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> grid[i][j]; int q; cin >> q; while (q--) { int x, y; int to; cin >> x >> y >> to; x--; y--; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) bad[i][j] = false; dfs(x, y, grid[x][y], to); } for (int i = 0; i < n; i++, cout << '\n') for (int j = 0; j < m; j++) cout << grid[i][j] << " "; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef _LOCAL_ system("color a"); #endif // _LOCAL_ int t = 1; while (t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...