Submission #592998

# Submission time Handle Problem Language Result Execution time Memory
592998 2022-07-10T05:17:26 Z czhang2718 Land of the Rainbow Gold (APIO17_rainbow) C++17
38 / 100
71 ms 20628 KB
#include "bits/stdc++.h"
#include "rainbow.h"
using namespace std;

const int N=1001;
int r, c, sx, sy, m;
string s;
bool g[N][N];
int ex[N][N], ey[N][N], v[N][N], two[N][N];
int lx, ly, rx, ry;

void init(int R, int C, int sr, int sc, int M, char *S) {
    r=R; c=C; sx=sr; sy=sc; m=M; s=S;
    int x=sx, y=sy;
    lx=rx=x;
    ly=ry=y;
    g[x][y]=1;
    for(char c:s){
        if(c=='N') x--;
        if(c=='S') x++;
        if(c=='W') y--;
        if(c=='E') y++;
        g[x][y]=1;
        lx=min(lx, x);
        rx=max(rx, x);
        ly=min(ly, y);
        ry=max(ry, y);
    }

    for(int i=1; i<=r; i++){
        for(int j=1; j<=c; j++){
            ex[i][j]=ex[i-1][j]+ex[i][j-1]-ex[i-1][j-1]+(!g[i][j]&&!g[i-1][j]);
            ey[i][j]=ey[i-1][j]+ey[i][j-1]-ey[i-1][j-1]+(!g[i][j]&&!g[i][j-1]);
            v[i][j]=v[i-1][j]+v[i][j-1]-v[i-1][j-1]+!g[i][j];
            two[i][j]=two[i-1][j]+two[i][j-1]-two[i-1][j-1]+(!g[i][j]&&!g[i-1][j]&&!g[i][j-1]&&!g[i-1][j-1]);
        }
    }
}

int rect(int a[][N], int x1, int y1, int x2, int y2){
    return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
}

int colour(int ar, int ac, int br, int bc) {
    int V=rect(v,ar,ac,br,bc);
    int E=rect(ex,ar+1,ac,br,bc)+rect(ey,ar,ac+1,br,bc);
    int F=rect(two,ar+1,ac+1,br,bc)+(ar<lx&&br>rx&&ac<ly&&bc>ry);
    // cout << V << "-" << E << "+" << F << '\n';
    return V-E+F;
}
// add 1 face if rectangles covers region!
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1196 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Incorrect 53 ms 7116 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Runtime error 2 ms 852 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1196 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 70 ms 20628 KB Output is correct
19 Correct 49 ms 5432 KB Output is correct
20 Correct 51 ms 5332 KB Output is correct
21 Correct 46 ms 7092 KB Output is correct
22 Correct 52 ms 9036 KB Output is correct
23 Correct 44 ms 5452 KB Output is correct
24 Correct 44 ms 5324 KB Output is correct
25 Correct 45 ms 7012 KB Output is correct
26 Correct 46 ms 8988 KB Output is correct
27 Correct 67 ms 20088 KB Output is correct
28 Correct 69 ms 20020 KB Output is correct
29 Correct 68 ms 19892 KB Output is correct
30 Correct 71 ms 20124 KB Output is correct
31 Correct 2 ms 580 KB Output is correct
32 Correct 58 ms 19920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1196 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 1 ms 1108 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 70 ms 20628 KB Output is correct
19 Correct 49 ms 5432 KB Output is correct
20 Correct 51 ms 5332 KB Output is correct
21 Correct 46 ms 7092 KB Output is correct
22 Correct 52 ms 9036 KB Output is correct
23 Correct 44 ms 5452 KB Output is correct
24 Correct 44 ms 5324 KB Output is correct
25 Correct 45 ms 7012 KB Output is correct
26 Correct 46 ms 8988 KB Output is correct
27 Correct 67 ms 20088 KB Output is correct
28 Correct 69 ms 20020 KB Output is correct
29 Correct 68 ms 19892 KB Output is correct
30 Correct 71 ms 20124 KB Output is correct
31 Correct 2 ms 580 KB Output is correct
32 Correct 58 ms 19920 KB Output is correct
33 Runtime error 2 ms 852 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -