답안 #911111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
911111 2024-01-18T13:02:59 Z lighton 무지개나라 (APIO17_rainbow) C++17
0 / 100
634 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;
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;
    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);
    }

    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);
    return 1-v+ex+ey-f;
}

# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 634 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -