Submission #401060

# Submission time Handle Problem Language Result Execution time Memory
401060 2021-05-09T09:53:30 Z A_D Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
3000 ms 5708 KB
//#include "rainbow.h"

#include <bits/stdc++.h>
/*

static int R, C, M, Q;
static int sr, sc;
static char S[100000 + 5];

*/

#define LL long long

using namespace std;













const int N=51;
bool a[N][N];
bool vis[N][N];
int mnr,mnc,mxr,mxc;
int x[]={0,0,1,-1};
int y[]={1,-1,0,0};
bool ok(int i,int j)
{
    return vis[i][j]==0&&a[i][j]==0&&mnr<=i&&i<=mxr&&mnc<=j&&j<=mxc;
}
void dfs(int i,int j)
{
    vis[i][j]=1;
    for(int k=0;k<4;k++){
        int ni=i+x[k];
        int nj=j+y[k];
        if(ok(ni,nj)){
            dfs(ni,nj);
        }
    }
}
void init(int R, int C, int sr, int sc, int M, char *S) {
//    cout<<5<<endl;
    string s;
        s+=S;
        /*
    for(int i=1;i<=M;i++){
        cout<<s<<endl;
        S++;
    }
    cout<<s<<endl;
    */
    int x=sr;
    int y=sc;
    a[x][y]=1;
    for(auto z:s){
        if(z=='N'){
            x--;
        }
        if(z=='S'){
            x++;
        }
        if(z=='W'){
            y--;
        }
        if(z=='E'){
            y++;
        }
        a[x][y]=1;
    }
    /*
    for(int i=1;i<=R;i++){
        for(int j=1;j<=C;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    */
}

int colour(int ar, int ac, int br, int bc) {
    memset(vis,0,sizeof(vis));
    mnr=ar;
    mnc=ac;
    mxr=br;
    mxc=bc;
    int ans=0;
    for(int i=mnr;i<=mxr;i++){
        for(int j=mnc;j<=mxc;j++){
            if(a[i][j]==0&&vis[i][j]==0){
                ans++;
                dfs(i,j);
            }
        }
    }
    return ans;
}
/*


int main() {
    scanf("%d %d %d %d", &R, &C, &M, &Q);
    scanf("%d %d", &sr, &sc);
    if (M > 0) {
        scanf(" %s ", S);
    }

    init(R, C, sr, sc, M, S);

    int query;
    for (query = 0; query < Q; query++) {
        int ar, ac, br, bc;
        scanf("%d %d %d %d", &ar, &ac, &br, &bc);
        printf("%d\n", colour(ar, ac, br, bc));
    }

    return 0;
}


*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 15 ms 464 KB Output is correct
4 Correct 15 ms 448 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 404 KB Output is correct
13 Correct 8 ms 312 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 6 ms 5708 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Runtime error 2 ms 844 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 15 ms 464 KB Output is correct
4 Correct 15 ms 448 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 404 KB Output is correct
13 Correct 8 ms 312 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Execution timed out 3075 ms 2428 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 15 ms 464 KB Output is correct
4 Correct 15 ms 448 KB Output is correct
5 Correct 6 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 404 KB Output is correct
13 Correct 8 ms 312 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Execution timed out 3075 ms 2428 KB Time limit exceeded
19 Halted 0 ms 0 KB -