Submission #908061

# Submission time Handle Problem Language Result Execution time Memory
908061 2024-01-16T07:37:03 Z ibm2006 Paint (COI20_paint) C++17
8 / 100
3000 ms 13448 KB
#include<bits/stdc++.h>
using namespace std;
typedef 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]=t;
    if(a[x][y]==a[x+1][y]&&c[x+1][y]!=t)
        f(x+1,y,z);
    if(a[x][y]==a[x-1][y]&&c[x-1][y]!=t)
        f(x-1,y,z);
        if(a[x][y]==a[x][y+1]&&c[x][y+1]!=t)
        f(x,y+1,z);
        if(a[x][y]==a[x][y-1]&&c[x][y-1]!=t)
        f(x,y-1,z);
        a[x][y]=z;
}
int main()
{
    scanf("%d %d",&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("%d",&a[i][j]);
        }
    }
    scanf("%lld",&e);
    for(ee=0;ee<e;ee++)
    {
        scanf("%d %d %d",&x,&y,&z);
        t++;
        f(x,y,z);
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            printf("%d ",a[i][j]);
        }
        printf("\n");
    }
}

Compilation message

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]!=t)
      |     ^~
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]!=t)
      |         ^~
paint.cpp: In function 'int main()':
paint.cpp:43:15: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'll*' {aka 'int*'} [-Wformat=]
   43 |     scanf("%lld",&e);
      |            ~~~^  ~~
      |               |  |
      |               |  ll* {aka int*}
      |               long long int*
      |            %d
paint.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
paint.cpp:40:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |             scanf("%d",&a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~
paint.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%lld",&e);
      |     ~~~~~^~~~~~~~~~~
paint.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%d %d %d",&x,&y,&z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 3 ms 364 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Correct 155 ms 1108 KB Output is correct
6 Correct 389 ms 1116 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1628 KB Output is correct
2 Correct 142 ms 3668 KB Output is correct
3 Execution timed out 3041 ms 11072 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 13448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 3992 KB Output is correct
2 Execution timed out 3098 ms 8016 KB Time limit exceeded
3 Halted 0 ms 0 KB -