Submission #1223400

#TimeUsernameProblemLanguageResultExecution timeMemory
1223400iulia_morariuPaint (COI20_paint)C++20
0 / 100
3086 ms453180 KiB
#include <algorithm> #include <iostream> #include <fstream> #include <climits> #include <vector> #include <stack> #include <cmath> #include <queue> // #include <bits/stdc++.h> #define in cin #define out cout #define mkp make_pair using namespace std; vector< vector<int> > v; int ox[] = {0, 0, 1, -1}; int oy[] = {1, -1, 0, 0}; void fill(int x, int y, int c){ int ini = v[x][y]; if(ini == c) return; v[x][y] = c; queue< pair<int, int> > q; q.push( mkp(x, y) ); while(!q.empty()){ x = q.front().first; y = q.front().second; q.pop(); v[x][y] = c; for(int i = 0; i < 4; i++){ if(x + ox[i] < 0 || x + ox[i] >= v.size() || y + oy[i] < 0 || y + oy[i] >= v[x].size()) continue; if(v[x + ox[i]][y + oy[i]] == ini){ q.push(mkp(x + ox[i], y + oy[i])); } } } } signed main(){ ios_base::sync_with_stdio(false); in.tie(NULL); int n, m; in >> n >> m; v.resize(n); for(int i = 0; i < n; i++) v[i].resize(m); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++) in >> v[i][j]; } int q; in >> q; if(q <= 10000 && n * m * q <= 300000000){ for(int i = 0; i < q; i++){ int x, y, c; in >> x >> y >> c; x--; y--; fill(x, y, c); } for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++) out << v[i][j] << " "; out << '\n'; } return 0; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...