Submission #887739

# Submission time Handle Problem Language Result Execution time Memory
887739 2023-12-15T06:58:23 Z hamidh100 Land of the Rainbow Gold (APIO17_rainbow) C++17
12 / 100
44 ms 8528 KB
#include "rainbow.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
#define PB push_back
#define MP make_pair
#define all(a) (a).begin(), (a).end()
#define endl '\n'
#define dbg(x) cerr << '[' << #x << ": " << x << "]\n"
#define dbg2(x, y) cerr << '[' << #x << ": " << x << ", " << #y << ": " << y << "]\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"

const ll INF = (ll)2e18 + 1386;
const ld EPS = 0.000000000000001;
const int MOD = 1e9 + 7;

inline int _add(int a, int b){ int res = a + b; return (res >= MOD ? res - MOD : res); }
inline int _neg(int a, int b){ int res = (abs(a - b) < MOD ? a - b : (a - b) % MOD); return (res < 0 ? res + MOD : res); }
inline int _mlt(ll a, ll b){ return (a * b % MOD); }
inline void fileIO(string i, string o){ freopen(i.c_str(), "r", stdin); freopen(o.c_str(), "w", stdout); }

const int MAXN = 2e5 + 5;

int n, m;
int a[MAXN][3];

inline int c(int x, int y){ return (x - 1) * m + y; }

int ps[MAXN][3];

void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R, m = C;
    a[sc][sr] = 1;
    for (int i = 0; i < M; i++){
        char ch = S[i];
        if (ch == 'N') a[sc][--sr] = 1;
        else if (ch == 'S') a[sc][++sr] = 1;
        else if (ch == 'E') a[++sc][sr] = 1;
        else a[--sc][sr] = 1;
    }
    for (int i = 1; i <= m; i++){
        ps[i][1] = ps[i - 1][1] + (a[i - 1][1] == 1 && a[i][1] == 0);
        ps[i][2] = ps[i - 1][2] + (a[i - 1][2] == 1 && a[i][2] == 0);
        ps[i][0] = ps[i - 1][0] + ((a[i - 1][1] == 1 && a[i][1] == 0 && !(a[i][2] == 0 && a[i - 1][2] == 0)) ||
                                   (a[i - 1][2] == 1 && a[i][2] == 0 && !(a[i][1] == 0 && a[i - 1][1] == 0)));
    }
}

int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};

int colour(int ar, int ac, int br, int bc) {
    if (ar == br){
        return ps[bc][ar] - ps[ac - 1][ar] + (a[ac][ar] == 0 && a[ac - 1][ar] == 0);
    }
    return ps[bc][0] - ps[ac - 1][0] + ((a[ac - 1][1] == 0 && a[ac][1] == 0) || (a[ac - 1][2] == 0 && a[ac][2] == 0));
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2648 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 40 ms 7896 KB Output is correct
4 Correct 41 ms 8528 KB Output is correct
5 Correct 41 ms 8272 KB Output is correct
6 Correct 41 ms 8272 KB Output is correct
7 Correct 40 ms 8300 KB Output is correct
8 Correct 39 ms 8272 KB Output is correct
9 Correct 44 ms 8308 KB Output is correct
10 Correct 40 ms 8120 KB Output is correct
11 Correct 40 ms 8276 KB Output is correct
12 Correct 38 ms 8216 KB Output is correct
13 Correct 38 ms 8276 KB Output is correct
14 Correct 42 ms 8172 KB Output is correct
15 Correct 41 ms 8276 KB Output is correct
16 Correct 40 ms 8080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Incorrect 2 ms 4956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -