Submission #250751

# Submission time Handle Problem Language Result Execution time Memory
250751 2020-07-19T04:11:11 Z balbit Land of the Rainbow Gold (APIO17_rainbow) C++14
12 / 100
91 ms 6648 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define f first
#define s second

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S&&...y){cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif // BALBIT

#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

#ifndef BALBIT
#include "rainbow.h"
#endif

int n,m;
vector<pii> pts;

bool H(pii &p) {
    return *lower_bound(ALL(pts), p) == p;
}
const int maxn = 3e5+5;
bool g[2][maxn];
int ps[2][maxn];

void init(int R, int C, int sr, int sc, int M, char *S) {
    n = R, m = C;
    pts.pb({sr, sc});
    g[sr-1][sc-1] = 1;
    for (int i = 0; i<M; ++i) {
        if (S[i] == 'N') {
            --sr;
        }
        if (S[i] == 'S') {
            ++sr;
        }
        if (S[i] == 'E') {
            ++sc;
        }
        if (S[i] == 'W') {
            --sc;
        }
        g[sr-1][sc-1] = 1;
    }
    for (int j = 0; j<2; ++j) for (int i = 1; i<maxn; ++i) {
        ps[j][i] = ps[j][i-1] + (g[j][i]!=g[j][i-1]);
    }
//    sort(ALL(pts));
//    pts.resize(unique(ALL(pts)) - pts.begin());
}

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

int r1, c1, r2, c2;


map<pii, int> dir;


int colour(int R1, int C1, int R2, int C2) {
    tie(r1,c1,r2,c2) = tie(R1,C1,R2,C2);
    -- r1; -- c1; --r2; --c2;
    if (c1 == c2) {
        if( r1 == r2) return g[r1][c1] == 0;
        if (g[r1][c1] != g[r2][c1]) return 1;
        return g[r1][c1] == 0;
    }
    if( r1 == r2) {
        int tmp = (ps[r1][c2] - ps[r1][c1]+1 + (g[r1][c1] == 0))/2;
        return tmp;
    }else{
        int tmp = (ps[r1][c2] - ps[r1][c1] + ps[r2][c2] - ps[r2][c1] + (g[r1][c1] != g[r2][c1]) + (g[r1][c2] != g[r2][c2]) );
        assert(tmp % 2 == 0);
        tmp/=2;
        if (tmp == 0) return g[r1][c1] == 0;
        else return tmp;
    }
    assert(0);
    return 0;
}





#ifdef BALBIT
signed main(){
    IOS();

}
#endif
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2688 KB Output is correct
2 Correct 4 ms 2688 KB Output is correct
3 Correct 71 ms 6520 KB Output is correct
4 Correct 75 ms 6520 KB Output is correct
5 Correct 91 ms 6520 KB Output is correct
6 Correct 80 ms 6396 KB Output is correct
7 Correct 67 ms 6520 KB Output is correct
8 Correct 70 ms 6392 KB Output is correct
9 Correct 83 ms 6524 KB Output is correct
10 Correct 79 ms 6648 KB Output is correct
11 Correct 71 ms 6392 KB Output is correct
12 Correct 63 ms 6392 KB Output is correct
13 Correct 66 ms 6520 KB Output is correct
14 Correct 60 ms 6520 KB Output is correct
15 Correct 60 ms 6392 KB Output is correct
16 Correct 76 ms 6392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Runtime error 1 ms 640 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 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -