# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
381561 |
2021-03-25T09:56:52 Z |
Araragi |
Paint (COI20_paint) |
C++17 |
|
17 ms |
7020 KB |
#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}};
string grid[100001];
bool bad[10001][10001];
int n, m;
void dfs(int x, int y, char who, char 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[x][y])
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;
char 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 time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
6892 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
17 ms |
6892 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
6892 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
7020 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |