Submission #201161

# Submission time Handle Problem Language Result Execution time Memory
201161 2020-02-09T13:26:56 Z BThero Land of the Rainbow Gold (APIO17_rainbow) C++17
11 / 100
3000 ms 2888 KB
// 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 time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 9 ms 380 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 9 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 11 ms 376 KB Output is correct
12 Correct 11 ms 504 KB Output is correct
13 Correct 11 ms 508 KB Output is correct
14 Correct 9 ms 504 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Execution timed out 3071 ms 1412 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Runtime error 8 ms 2296 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 9 ms 380 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 9 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 11 ms 376 KB Output is correct
12 Correct 11 ms 504 KB Output is correct
13 Correct 11 ms 508 KB Output is correct
14 Correct 9 ms 504 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Execution timed out 3053 ms 2888 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 9 ms 380 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 9 ms 504 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 11 ms 376 KB Output is correct
12 Correct 11 ms 504 KB Output is correct
13 Correct 11 ms 508 KB Output is correct
14 Correct 9 ms 504 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Execution timed out 3053 ms 2888 KB Time limit exceeded
19 Halted 0 ms 0 KB -