Submission #920483

#TimeUsernameProblemLanguageResultExecution timeMemory
920483ErJPaint (COI20_paint)C++17
8 / 100
349 ms4188 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...