제출 #1003905

#제출 시각아이디문제언어결과실행 시간메모리
1003905PagodePaivaPaint (COI20_paint)C++17
8 / 100
3071 ms16436 KiB
#include<bits/stdc++.h> using namespace std; vector <vector <int>> v; int r, s; bool check(int a, int b){ return (a >= 0 and a < r and b >= 0 and b < s); } void dfs(int a, int b, int cor1, int cor2){ if(v[a][b] == cor1) v[a][b] = cor2; else return; if(check(a-1, b)) dfs(a-1, b, cor1, cor2); if(check(a+1, b)) dfs(a+1, b, cor1, cor2); if(check(a, b-1)) dfs(a, b-1, cor1, cor2); if(check(a, b+1)) dfs(a, b+1, cor1, cor2); return; } int main(){ cin >> r >> s; for(int i = 0;i < r;i++){ vector <int> aux; for(int i = 0;i < s;i++){ int x; cin >> x; aux.push_back(x); } v.push_back(aux); } int q; cin >> q; while(q--){ int l, r, cor; cin >> l >> r >> cor; l--; r--; if(v[l][r] == cor) continue; dfs(l, r, v[l][r], cor); } for(auto x : v){ for(auto y : x){ cout << y << ' '; } cout << endl; } 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...