This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
#define bug(x) cout << #x << " " << x << endl;
const int maxn = 60;
const int inf = 1e9;
int marc[maxn][maxn];
int n, m, q;
int di[] = { 0, 1, 0, -1 };
int dj[] = { 1, 0, -1, 0 };
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
marc[sr][sc] = inf;
for( int i = 0; i < M; i++ ){
char c = S[i];
if( c == 'N' ) sr--;
if( c == 'S' ) sr++;
if( c == 'W' ) sc--;
if( c == 'E' ) sc++;
marc[sr][sc] = inf;
}
}
int linha1, linha2, coluna1, coluna2;
bool in_bounds( int i, int j ){
return linha1 <= i && i <= linha2 && coluna1 <= j && j <= coluna2;
}
void dfs( int i, int j ){
// bug(i);
// bug(j);
marc[i][j] = q;
for( int d = 0; d < 4; d++ ) if( marc[i + di[d]][j + dj[d]] < q && in_bounds( i + di[d], j + dj[d] ) ) dfs( i + di[d], j + dj[d] );
}
int colour(int ar, int ac, int br, int bc) {
linha1 = ar; coluna1 = ac; linha2 = br; coluna2 = bc;
q++;
// bug(ar);
// bug(ac);
// bug(br);
// bug(bc);
int resp = 0;
for( int i = ar; i <= br; i++ )
for( int j = ac; j <= bc; j++ ){
// cout << i << " " << j << " " << marc[i][j] << endl;
if( marc[i][j] < q ){ resp++; dfs( i, j ); }
}
return resp;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |