Submission #1003948

#TimeUsernameProblemLanguageResultExecution timeMemory
1003948vjudge1Paint (COI20_paint)C++17
8 / 100
3073 ms15040 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int,int> #define ff first #define ss second const int maxn = 1e3+5; vector<vector<int>> mtx, mark; int dx[4] = {1,-1,0,0}, dy[4] = {0,0,1,-1}; int n,m; bool valid(int x, int y){ return (x>0 && y>0 && x<=n && y<=m && !mark[x][y]); } void dfs(int x, int y, int cor){ // cout << x << " " << y << endl; mark[x][y]=true; for(int i=0; i<4; i++){ int vx = x+dx[i]; int vy = y+dy[i]; if(valid(vx,vy) && mtx[x][y]==mtx[vx][vy]) dfs(vx,vy,cor); } mtx[x][y]=cor; } int main(){ cin >> n >> m; mtx.resize(n+5); mark.resize(n+5); for(int i=1; i<=n; i++) mtx[i].resize(m+5), mark[i].resize(m+5); for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ int x; cin >> x; mtx[i][j]=x; } } int q; cin >> q; for(int i=1; i<=q; i++){ int x,y,c; cin >> x >> y >> c; dfs(x,y,c); for(int j=1; j<=n; j++){ for(int k=1; k<=m; k++) mark[j][k]=false; } } for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ cout << mtx[i][j] << " "; } cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...