Submission #536656

# Submission time Handle Problem Language Result Execution time Memory
536656 2022-03-13T17:02:52 Z ammar2000 Land of the Rainbow Gold (APIO17_rainbow) C++17
11 / 100
15 ms 828 KB
#include "rainbow.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
//#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
#define sc(x) scanf("%lld",&x)
#define all(x) x.begin(),x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int dx[] = {1 , -1 , 0 , 0};
int dy[] = {0 , 0 , 1 , -1};
int MOD=1e9+7;
ll n,m,g[55][55];
ll vis[55][55],col;
ll u,l,d,r;
bool valid(int x,int y)
{
    return x>=u&&x<=d&&y>=l&&y<=r&&g[x][y]==0&&vis[x][y]!=col;
}
void dfs(int x,int y)
{
 //   cout <<x<<" "<<y<<"\n";
    vis[x][y]=col;
    for (int i=0;i<4;i++)
    {
        if (valid(x+dx[i],y+dy[i]))
            dfs(x+dx[i],y+dy[i]);
    }
}
void init(int R, int C, int sr, int sc, int M, char *S) {
     n=R,m=C;
    g[sr][sc]=1;
    for (int i=0;i<M;i++)
    {
        if (S[i]=='N')
            sr--;
        else if (S[i]=='S')
            sr++;
        else if (S[i]=='E')
            sc++;
        else sc--;
        g[sr][sc]=1;
    }

}

int colour(int ar, int ac, int br, int bc) {
    col++;
    u=ar,l=ac,d=br,r=bc;
    ll ret=0;
    for (int i=ar;i<=br;i++)
        for (int u=ac;u<=bc;u++)
    {
        if (vis[i][u]!=col&&g[i][u]==0)
            ret++,dfs(i,u);
    }
    return ret;
}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 392 KB Output is correct
3 Correct 15 ms 468 KB Output is correct
4 Correct 15 ms 468 KB Output is correct
5 Correct 6 ms 424 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 11 ms 468 KB Output is correct
12 Correct 13 ms 448 KB Output is correct
13 Correct 8 ms 468 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Runtime error 1 ms 680 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 392 KB Output is correct
3 Correct 15 ms 468 KB Output is correct
4 Correct 15 ms 468 KB Output is correct
5 Correct 6 ms 424 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 11 ms 468 KB Output is correct
12 Correct 13 ms 448 KB Output is correct
13 Correct 8 ms 468 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Runtime error 1 ms 828 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 6 ms 392 KB Output is correct
3 Correct 15 ms 468 KB Output is correct
4 Correct 15 ms 468 KB Output is correct
5 Correct 6 ms 424 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 11 ms 468 KB Output is correct
12 Correct 13 ms 448 KB Output is correct
13 Correct 8 ms 468 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 1 ms 300 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Runtime error 1 ms 828 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -