Submission #393706

# Submission time Handle Problem Language Result Execution time Memory
393706 2021-04-24T10:37:23 Z sad Paint (COI20_paint) C++14
8 / 100
3000 ms 11232 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=10003;
vector<int>a[N],vis[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;
    for(int i=0;i<n+3;i++)
    {
        for(int j=0;j<m+3;j++)
        {
            a[i].pb(-1);
            vis[i].pb(0);
        }
    }
    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);
        for(int i=0;i<n+3;i++)
        {
            for(int j=0;j<m+3;j++)vis[i][j]=0;
        }
    }
    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<m+1;j++)cout<<a[i][j]<<" ";
        cout<<endl;
    }

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 716 KB Output is correct
3 Correct 40 ms 980 KB Output is correct
4 Correct 50 ms 944 KB Output is correct
5 Correct 453 ms 1336 KB Output is correct
6 Correct 1039 ms 1740 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3080 ms 3108 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3004 ms 11232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 2744 KB Time limit exceeded
2 Halted 0 ms 0 KB -