답안 #393705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393705 2021-04-24T10:30:07 Z sad Paint (COI20_paint) C++14
0 / 100
278 ms 524292 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
int n,m;
const int N=10019;
int a[N][N],vis[N][N];
void dfs (int x,int y,int c)
{
    if(vis[x][y])return;
    if(x==n+1||x==0||y==m+1||y==0)
    {
        return;
    }
    vis[x][y]=1;
    if(a[x][y]==a[x-1][y])dfs(x-1,y,c);
    if(a[x][y]==a[x+1][y])dfs(x+1,y,c);
    if(a[x][y]==a[x][y+1])dfs(x,y+1,c);
    if(a[x][y]==a[x][y-1])dfs(x,y-1,c);
    a[x][y]=c;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    memset(a,-1,sizeof a);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<m+1;j++)
        {
            cin>>a[i][j];
        }
    }
    int q;cin>>q;
    while(q--)
    {
        int x,y,c;
        cin>>x>>y>>c;
        dfs(x,y,c);
        memset(vis,0,sizeof vis);
    }
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<m+1;j++)cout<<a[i][j]<<" ";
        cout<<endl;
    }

}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 269 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 251 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 276 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 278 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -