Submission #55486

# Submission time Handle Problem Language Result Execution time Memory
55486 2018-07-07T17:01:34 Z top34051 Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
4 ms 688 KB
#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 2e5 + 5;

int n,m,k;
int a[55][55];
int p[55][55];

void init(int N, int M, int sx, int sy, int K, char *s) {
	n = N; m = M; k = K;
	int x = sx, y = sy;
	a[x][y] = 1;
	for(int i=0;i<k;i++) {
        if(s[i]=='N') x--;
        if(s[i]=='E') y++;
        if(s[i]=='W') y--;
        if(s[i]=='S') x++;
        a[x][y] = 1;
	}
}

int colour(int r1, int c1, int r2, int c2) {
    int ok = 0;
    for(int x=r1;x<=r2;x++) {
        for(int y=c1;y<=c2;y++) {
            if(x==r1 || x==r2 || y==c1 || y==c2) ok |= a[x][y];
        }
    }
    for(int x=r1-1;x<=r2+1;x++) {
        for(int y=c1-1;y<=c2+1;y++) {
            if(x==r1-1 || x==r2+1 || y==c1-1 || y==c2+1) p[x][y] = ok;
            else p[x][y] = a[x][y];
        }
    }
    int v = 0, e = 0;
    for(int x=r1-1;x<=r2+1;x++) {
        for(int y=c1-1;y<=c2+1;y++) {
//            printf("%d",p[x][y]);
            if(p[x][y]) v++;
            if(y+1<=c2+1 && p[x][y] && p[x][y+1]) e++;
            if(x+1<=r2+1 && p[x][y] && p[x+1][y]) e++;
        }
//        printf("\n");
    }
    int res = e-v+1;
//    printf("res = %d\n",res);
    for(int x=r1-1;x<=r2;x++) {
        for(int y=c1-1;y<=c2;y++) {
            if(p[x][y] && p[x][y+1] && p[x+1][y] && p[x+1][y+1]) res--;
        }
    }
    return res + !ok;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 488 KB Output is correct
2 Runtime error 3 ms 688 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 Incorrect 4 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -