Submission #262466

# Submission time Handle Problem Language Result Execution time Memory
262466 2020-08-13T00:28:25 Z daniel920712 Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
3000 ms 1016 KB
#include "rainbow.h"
#include <queue>
#include <utility>
using namespace std;
bool all[55][200005]={0};
bool have[55][200005]={0};
int dx[5]={1,0,-1,0};
int dy[5]={0,-1,0,1};
queue < pair < int , int > > BFS;
void init(int R, int C, int sr, int sc, int M, char *S)
{
    all[sr][sc]=1;
    int i;
    for(i=0;i<M;i++)
    {
        if(S[i]=='N') sr--;
        if(S[i]=='S') sr++;
        if(S[i]=='E') sc++;
        if(S[i]=='W') sc--;
        all[sr][sc]=1;
    }

}

int colour(int ar, int ac, int br, int bc)
{
    int ans=0,x,y,i,j,k;
    for(i=ar;i<=br;i++) for(j=ac;j<=bc;j++) have[i][j]=0;

    for(i=ar;i<=br;i++)
    {
        for(j=ac;j<=bc;j++)
        {
            if(!have[i][j]&&all[i][j]==0)
            {
                ans++;
                BFS.push(make_pair(i,j));
                have[i][j]=1;
                while(!BFS.empty())
                {
                    x=BFS.front().first;
                    y=BFS.front().second;
                    BFS.pop();

                    for(k=0;k<4;k++)
                    {
                        if(x+dx[k]>=ar&&x+dx[k]<=br&&y+dy[k]>=ac&&y+dy[k]<=bc&&!have[x+dx[k]][y+dy[k]]&&!all[x+dx[k]][y+dy[k]])
                        {
                            have[x+dx[k]][y+dy[k]]=1;
                            BFS.push(make_pair(x+dx[k],y+dy[k]));
                        }
                    }
                }
            }


        }
    }
    return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 8 ms 768 KB Output is correct
3 Correct 18 ms 768 KB Output is correct
4 Correct 18 ms 768 KB Output is correct
5 Correct 7 ms 768 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 16 ms 768 KB Output is correct
12 Correct 13 ms 768 KB Output is correct
13 Correct 10 ms 896 KB Output is correct
14 Correct 7 ms 768 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Execution timed out 3069 ms 1016 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 8 ms 768 KB Output is correct
3 Correct 18 ms 768 KB Output is correct
4 Correct 18 ms 768 KB Output is correct
5 Correct 7 ms 768 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 16 ms 768 KB Output is correct
12 Correct 13 ms 768 KB Output is correct
13 Correct 10 ms 896 KB Output is correct
14 Correct 7 ms 768 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 8 ms 768 KB Output is correct
3 Correct 18 ms 768 KB Output is correct
4 Correct 18 ms 768 KB Output is correct
5 Correct 7 ms 768 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 16 ms 768 KB Output is correct
12 Correct 13 ms 768 KB Output is correct
13 Correct 10 ms 896 KB Output is correct
14 Correct 7 ms 768 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -