제출 #381546

#제출 시각아이디문제언어결과실행 시간메모리
381546SlavitaPaint (COI20_paint)C++14
8 / 100
3091 ms3436 KiB
#include <bits/stdc++.h> #define ve vector<int> #define pb push_back #define mp make_pair #define fi first #define se second #define pi pair<int,int> #define all(v) v.begin(),v.end() #define si(v) (int)v.size() #define en '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; const int N = 1e4 + 228; const int big = 1e9; int n, m, b[N], curCol, col, re[N][N]; bool mrk[N][N]; queue<int> X, Y; void put(int x, int y){ if (x < 1 || x > n || y < 1 || y > m) return; if (mrk[x][y]) return; if (re[x][y] != curCol) return; re[x][y] = col; mrk[x][y] = 1; X.push(x); Y.push(y); } void go(int x, int y){ int st[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}}; for (int i = 0; i < 4; i++) { put(x + st[i][0], y + st[i][1]); } } int main(){ iostream::sync_with_stdio(false); cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); cin >> n >> m; for (int i = 1; i <= n; i++){ for (int j = 1; j <= m; j++){ int x; cin >> x; re[i][j] = x; } } int q; cin >> q; while(q--){ int x, y; cin >> x >> y >> col; curCol = re[x][y]; put(x, y); while(!X.empty()){ int x = X.front(); X.pop(); int y = Y.front(); Y.pop(); go(x, y); } for (int i = 1; i <= n; i++){ for (int j = 1; j <= m; j++){ mrk[i][j] = 0; } } } for (int i = 1; i <= n; i++){ for (int j = 1; j <= m; j++){ cout << re[i][j] << ' '; } cout << en; } return 0; } /* 12 11 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 2 2 2 0 0 0 1 1 0 0 0 2 2 2 0 0 0 1 1 0 0 0 2 2 2 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 9 0 0 0 1 1 0 1 1 0 0 9 0 0 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 4 12 11 1 5 11 2 4 4 2 6 6 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...