답안 #911113

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
911113 2024-01-18T13:07:32 Z lighton 무지개나라 (APIO17_rainbow) C++17
12 / 100
474 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 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 66 ms 29684 KB Output is correct
4 Correct 65 ms 29756 KB Output is correct
5 Correct 66 ms 29912 KB Output is correct
6 Correct 68 ms 29928 KB Output is correct
7 Correct 64 ms 29764 KB Output is correct
8 Correct 68 ms 29840 KB Output is correct
9 Correct 65 ms 29764 KB Output is correct
10 Correct 66 ms 29764 KB Output is correct
11 Correct 65 ms 29732 KB Output is correct
12 Correct 65 ms 29712 KB Output is correct
13 Correct 61 ms 29756 KB Output is correct
14 Correct 59 ms 29764 KB Output is correct
15 Correct 60 ms 29864 KB Output is correct
16 Correct 66 ms 29680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 474 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -