# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
500009 |
2021-12-30T09:16:09 Z |
kappa |
Paint (COI20_paint) |
C++14 |
|
3000 ms |
5180 KB |
#include <bits/stdc++.h>
#define st first
#define nd second
using namespace std;
long long a, b, q;
void solve(vector<vector<int> > &v){
long long x, y, col, vis[a + 2][b + 2];
memset(vis, 0, sizeof(vis));
pair<int, int> dir[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
cin >> x >> y >> col;
queue<pair<int, int> > q;
q.push({x, y});
while(!q.empty()){
pair<int, int> curr = q.front();
q.pop();
long long cx = curr.st, cy = curr.nd, currColor = v[cx][cy];
if(vis[cx][cy]) continue;
vis[cx][cy] = 1;
v[cx][cy] = col;
for (int i = 0; i < 4; i++)
{
if(!vis[cx + dir[i].first][cy + dir[i].second] && v[cx + dir[i].first][cy + dir[i].second] == currColor){
q.push({cx + dir[i].first, cy + dir[i].second});
}
}
}
}
int main(){
cin >> a >> b;
vector<vector<int> > d(a + 2, vector<int>(b + 2, 0));
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= b; j++)
{
cin >> d[i][j];
}
}
cin >> q;
while(q--){
solve(d);
}
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= b; j++)
{
cout << d[i][j] << " ";
}
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
216 KB |
Output is correct |
3 |
Correct |
17 ms |
424 KB |
Output is correct |
4 |
Correct |
18 ms |
392 KB |
Output is correct |
5 |
Correct |
624 ms |
484 KB |
Output is correct |
6 |
Runtime error |
2 ms |
588 KB |
Execution killed with signal 11 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3073 ms |
2804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
38 ms |
5180 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2280 ms |
2652 KB |
Output is correct |
2 |
Execution timed out |
3067 ms |
3908 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |