제출 #201161

#제출 시각아이디문제언어결과실행 시간메모리
201161BTheroLand of the Rainbow Gold (APIO17_rainbow)C++17
11 / 100
3071 ms2888 KiB
// Why am I so dumb? :c
// chrono::system_clock::now().time_since_epoch().count()
                                                  
#include<bits/stdc++.h>
#include "rainbow.h"
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;   
typedef pair<int, int> pii;
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int MAXN = (int)1e3 + 5;
const int MAXM = (int)1e5 + 5;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const char dc[] = {'E', 'S', 'W', 'N'};

int mnx, mxx, mny, mxy;

bool col[MAXN][MAXN];

pii arr[MAXM];

int n, m, k;

void init(int R, int C, int stx, int sty, int M, char *S) {
    n = R;
    m = C;
    k = M;
    arr[0] = mp(stx, sty);

    for (int i = 0; i < k; ++i) {
        int dir = find(dc, dc + 4, S[i]) - dc;
        stx += dx[dir];
        sty += dy[dir];
        arr[i + 1] = mp(stx, sty);                                
    }

    mnx = mxx = arr[0].fi;
    mny = mxy = arr[0].se;

    for (int i = 0; i <= k; ++i) {
        int x, y;
        tie(x, y) = arr[i];
        mnx = min(mnx, x);
        mxx = max(mxx, x);
        mny = min(mny, y);
        mxy = max(mxy, y);
        col[x][y] = 1;
    }
}

int colour(int ax, int ay, int bx, int by) {
    int ans = 1;

    if (ax < mnx && mxx < bx && ay < mny && mxy < by) {
        ++ans;        
    }    

    for (int i = ax; i < bx; ++i) {
        for (int j = ay; j <= by; ++j) {
            ans += (col[i][j] || col[i + 1][j]);
        }
    }

    for (int i = ax; i <= bx; ++i) {
        for (int j = ay; j < by; ++j) {
            ans += (col[i][j] || col[i][j + 1]);
        }
    }

    for (int i = ax; i < bx; ++i) {
        for (int j = ay; j < by; ++j) {
            ans -= (col[i][j] || col[i + 1][j] || col[i][j + 1] || col[i + 1][j + 1]);
        }
    }

    for (int i = ax; i <= bx; ++i) {
        for (int j = ay; j <= by; ++j) {
            ans -= col[i][j]; 
        }
    }

    return ans; 
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...