# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
920483 |
2024-02-02T15:31:03 Z |
ErJ |
Paint (COI20_paint) |
C++17 |
|
349 ms |
4188 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<pair<ll, ll>>
#define pp pair<ll, ll>
#define qi queue<ll>
#define qp queue<pp>
#define pqi priority_queue<ll>
#define pqp priority_queue<pp>
#define mi map<ll, ll>
#define mpi map<pp, ll>
#define mip map<ll, pp>
#define mpp map<pp, pp>
#define mb map<ll, bool>
#define si set<ll>
#define sp set<pp>
#define mod 1000000007
#define rep(a, b) for(int a = 0; a < (b); a++)
#define inf 1000000000000000000
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int r, s, q;
cin >> r >> s;
vvi table(r);
for (int i = 0; i < r; i++) {
table[i].resize(s);
for (int j = 0; j < s; j++) {
cin >> table[i][j];
}
}
cin >> q;
vector<pair<pp, int>> quest(q);
rep(i, q) {
int a, b, c;
cin >> a >> b >> c;
a--; b--;
quest[i] = { {a, b}, c };
}
vp sousedi = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };
if ((r * s <= 10000) && (q <= 10000)) {
for(int i = 0; i < q; i++){
queue<pp> fronta;
fronta.push(quest[i].first);
int xx = table[quest[i].first.first][quest[i].first.second];
if (xx == quest[i].second) continue;
while (!fronta.empty()) {
pp u = fronta.front();
table[u.first][u.second] = quest[i].second;
fronta.pop();
for (auto j : sousedi) {
if ((u.first + j.first) < r && (u.first + j.first) >= 0 && (u.second + j.second) < s && (u.second + j.second) >= 0) {
if (table[u.first + j.first][u.second + j.second] == xx) {
fronta.push({ u.first + j.first, u.second + j.second });
table[u.first + j.first][u.second + j.second] = quest[i].second;
}
}
}
}
}
rep(i, r) {
rep(j, s - 1) {
cout << table[i][j] << " ";
}
cout << table[i][s - 1] << endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
3 ms |
604 KB |
Output is correct |
5 |
Correct |
262 ms |
856 KB |
Output is correct |
6 |
Correct |
349 ms |
688 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
4188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
2908 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
3676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |