Submission #911116

# Submission time Handle Problem Language Result Execution time Memory
911116 2024-01-18T13:15:35 Z lighton Land of the Rainbow Gold (APIO17_rainbow) C++17
50 / 100
546 ms 1048576 KB
#include "rainbow.h"
#include <bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
using namespace std;
typedef long long ll;
int r,c;
int minr,maxr,minc,maxc;
struct ST{
    int row,col;
    vector<vector<int> > arr;
    vector<vector<int> > ps;
    void init(int R, int C){
        row = R;
        col = C;
        arr.resize(R+2,vector<int>(C+2,0));
        ps.resize(R+2,vector<int>(C+2,0));
    }
    void psum(){
        forf(i,1,row+1){
            forf(j,1,col+1){
                ps[i][j] = arr[i][j]+ps[i-1][j]+ps[i][j-1]-ps[i-1][j-1];
            }
        }
    }
    int query(int r1, int c1, int r2, int c2){
        return ps[r2][c2] - ps[r1-1][c2] - ps[r2][c1-1] + ps[r1-1][c1-1];
    }
} F,V,Ex,Ey;

void mark(int row, int col){
    F.arr[row][col] = 1;
    V.arr[row][col] = 1; V.arr[row+1][col] = 1; V.arr[row][col+1] = 1; V.arr[row+1][col+1] = 1;
    Ex.arr[row][col] = 1; Ex.arr[row+1][col] = 1;
    Ey.arr[row][col] = 1; Ey.arr[row][col+1] = 1;
}

void init(int R, int C, int sr, int sc, int M, char *S) {
    r=R;c=C;
    F.init(r,c);V.init(r,c);Ex.init(r,c);Ey.init(r,c);

    int row = sr, col =sc;
    minr = row; maxr = row; minc = col; maxc = col;
    mark(row,col);
    forf(i,0,M-1){
        if(S[i] == 'N') row--;
        if(S[i] == 'S') row++;
        if(S[i] == 'E') col++;
        if(S[i] == 'W') col--;
        mark(row,col);
        minr = min(minr,row); maxr = max(maxr,row);
        minc = min(minc,col); maxc = max(maxc,col);
    }

    F.psum();V.psum();Ex.psum();Ey.psum();
}

int colour(int ar, int ac, int br, int bc) {
    int f = F.query(ar,ac,br,bc);
    int v = V.query(ar+1,ac+1,br,bc);
    int ex = Ex.query(ar+1,ac,br,bc);
    int ey = Ey.query(ar,ac+1,br,bc);
    int p = 0;
    if(ar<minr && br>maxr && ac<minc && bc>maxc) p = 1;
    return 1-v+ex+ey-f+p;
}

# 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 1 ms 348 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 101 ms 29684 KB Output is correct
4 Correct 78 ms 29508 KB Output is correct
5 Correct 70 ms 29508 KB Output is correct
6 Correct 70 ms 29428 KB Output is correct
7 Correct 78 ms 29508 KB Output is correct
8 Correct 95 ms 29440 KB Output is correct
9 Correct 89 ms 29416 KB Output is correct
10 Correct 72 ms 29504 KB Output is correct
11 Correct 72 ms 29508 KB Output is correct
12 Correct 61 ms 29624 KB Output is correct
13 Correct 61 ms 29504 KB Output is correct
14 Correct 61 ms 29504 KB Output is correct
15 Correct 68 ms 29412 KB Output is correct
16 Correct 72 ms 29524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 546 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 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 1 ms 348 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 98 ms 35664 KB Output is correct
19 Correct 44 ms 6996 KB Output is correct
20 Correct 47 ms 4180 KB Output is correct
21 Correct 45 ms 5160 KB Output is correct
22 Correct 50 ms 6996 KB Output is correct
23 Correct 47 ms 6876 KB Output is correct
24 Correct 41 ms 4200 KB Output is correct
25 Correct 42 ms 4948 KB Output is correct
26 Correct 45 ms 6996 KB Output is correct
27 Correct 94 ms 35732 KB Output is correct
28 Correct 103 ms 35524 KB Output is correct
29 Correct 96 ms 35732 KB Output is correct
30 Correct 113 ms 35692 KB Output is correct
31 Correct 2 ms 456 KB Output is correct
32 Correct 76 ms 35536 KB Output is correct
# 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 1 ms 348 KB Output is correct
4 Correct 1 ms 572 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 98 ms 35664 KB Output is correct
19 Correct 44 ms 6996 KB Output is correct
20 Correct 47 ms 4180 KB Output is correct
21 Correct 45 ms 5160 KB Output is correct
22 Correct 50 ms 6996 KB Output is correct
23 Correct 47 ms 6876 KB Output is correct
24 Correct 41 ms 4200 KB Output is correct
25 Correct 42 ms 4948 KB Output is correct
26 Correct 45 ms 6996 KB Output is correct
27 Correct 94 ms 35732 KB Output is correct
28 Correct 103 ms 35524 KB Output is correct
29 Correct 96 ms 35732 KB Output is correct
30 Correct 113 ms 35692 KB Output is correct
31 Correct 2 ms 456 KB Output is correct
32 Correct 76 ms 35536 KB Output is correct
33 Runtime error 546 ms 1048576 KB Execution killed with signal 9
34 Halted 0 ms 0 KB -