제출 #1003951

#제출 시각아이디문제언어결과실행 시간메모리
1003951vjudge1Paint (COI20_paint)C++17
0 / 100
25 ms4700 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=10010; vector <int> v[MAXN],mark[MAXN]; int r, s; void dfs(int x, int y, int cor){ mark[x][y] = 1; if(x+1<=s && v[x+1][y]==v[x][y] && mark[x+1][y]==0) dfs(x+1, y, cor); if(x-1>0 && v[x-1][y]==v[x][y] && mark[x-1][y]==0) dfs(x-1, y, cor); if(y+1<=r && v[x][y+1]==v[x][y] && mark[x][y+1]==0) dfs(x, y+1, cor); if(y-1>0 && v[x][y-1]==v[x][y] && mark[x][y-1]==0) dfs(x, y-1, cor); v[x][y] = cor; } int main(){ cin >> r >> s; for(int i=1; i<=r; i++){ v[i].push_back(0); for(int j=1; j<=s; j++){ int x; cin >> x; v[i].push_back(x); } } /* for(int i=1; i<=r; i++){ for(int j=1; j<=s; j++) cout << v[i][j] << " "; cout << endl; } */ int q; cin >> q; for(int i=1; i<=r; i++){ for(int j=0; j<=s; j++){ mark[i].push_back(0); } } for(int i=0; i<q; i++){ int x, y, cor; cin >> x >> y >> cor; for(int j=1; j<=r; j++){ for(int k=1; k<=s; k++){ mark[j][k] = 0; } } dfs(x, y, cor); } for(int i=1; i<=r; i++){ for(int j=1; j<=s; j++){ cout << v[i][j] << " "; } cout << 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...