Submission #907964

#TimeUsernameProblemLanguageResultExecution timeMemory
907964ibm2006Paint (COI20_paint)C++17
0 / 100
3100 ms15312 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,i,j,k,l,r,x,y,z,w,s,t,e,ee,m;
vector<vector<ll>> a,c;
void f(ll x,ll y,ll z)
{
    c[x][y]=1;
    if(a[x][y]==a[x+1][y]&&c[x+1][y]==0)
        f(x+1,y,z);
    if(a[x][y]==a[x-1][y]&&c[x-1][y]==0)
        f(x-1,y,z);
        if(a[x][y]==a[x][y+1]&&c[x][y+1]==0)
        f(x,y+1,z);
        if(a[x][y]==a[x][y-1]&&c[x][y-1]==0)
        f(x,y-1,z);
        c[x][y]=0;
        a[x][y]=z;
}
int main()
{
    scanf("%lld %lld",&n,&m);
    a.resize(n+10);
    c.resize(n+10);
    for(i=0;i<=n+1;i++)
    {
        a[i].resize(m+10);
        c[i].resize(m+10);
    }
    for(i=0;i<=n+1;i++)
    {
        for(j=0;j<=m+1;j++)
        {
            a[i][j]=-1;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%lld",&a[i][j]);
        }
    }
    scanf("%lld",&e);
    for(ee=0;ee<e;ee++)
    {
        scanf("%lld %lld %lld",&x,&y,&z);
        f(x,y,z);
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            printf("%lld ",a[i][j]);
        }
        printf("\n");
    }
}

Compilation message (stderr)

paint.cpp: In function 'void f(ll, ll, ll)':
paint.cpp:11:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   11 |     if(a[x][y]==a[x-1][y]&&c[x-1][y]==0)
      |     ^~
paint.cpp:13:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   13 |         if(a[x][y]==a[x][y+1]&&c[x][y+1]==0)
      |         ^~
paint.cpp: In function 'int main()':
paint.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     scanf("%lld %lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
paint.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |             scanf("%lld",&a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
paint.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%lld",&e);
      |     ~~~~~^~~~~~~~~~~
paint.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf("%lld %lld %lld",&x,&y,&z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...