Submission #250749

# Submission time Handle Problem Language Result Execution time Memory
250749 2020-07-19T04:04:24 Z balbit Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
3 ms 2688 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]) )/2;
        if (tmp == 0) return g[r1][c1] == 0;
        else return tmp;
    }

    return 0;
}





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

}
#endif
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 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 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 384 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 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -