답안 #948304

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948304 2024-03-18T03:58:04 Z vjudge1 무지개나라 (APIO17_rainbow) C++17
0 / 100
3000 ms 1048576 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std ;

int n , m , x , y ;
string s ;
map < int , map <int , int>> vis ;
map <char , int> f , a ;

void init(int R, int C, int sr, int sc, int M, char *S) {
	f['N'] = -1 ; f['S'] = 1 ;
	a['E'] = 1 ; a['W'] = -1 ;
	n = R ; m = C ; x = sr , y = sc ; s = S ;
	for ( int i = 0 ; i < M ; i ++ ) x += f[s[i]] , y += a[s[i]] , vis[x][y] = 2 ;
	vis[sr][sc] = 2 ;
}

void dfs ( int i , int j ){
	vis[i][j] = 1 ;
	for ( int x = -1 ; x < 2 ; x ++ ){
		for ( int y = -1 ; y < 2 ; y ++ ){
			if ( x*y != 0 ) continue ;
			if ( x+i>0 && y+j > 0 && x+i <= n && y+j <= m && vis[i+x][y+j] == 0 ) dfs(i+x,y+j) ;
		}
	}
}

int colour(int ar, int ac, int br, int bc) {
	int ans = 0 ;
	for ( int i = ar ; i <= br ; i ++ ){
		for ( int j = ac ; j <= bc ; j ++ ){
			if ( vis[i][j] == 1 ) vis[i][j] = 0 ;
		}
	}
	for ( int i = ar ; i <= br ; i ++ ){
		for ( int j = ac ; j <= bc ; j ++ ){
			if ( vis[i][j] == 0 ){
				//cout << i << ' ' << j << endl; 
				ans ++ ; dfs(i,j) ;
			}
		}
	} 
    return ans ;
}

/*
static int R, C, M, Q;
static int sr, sc;
static char S[100000 + 5];

int main() {
    scanf("%d %d %d %d", &R, &C, &M, &Q);
    scanf("%d %d", &sr, &sc);
    if (M > 0) {
        scanf(" %s ", S);
    }

    init(R, C, sr, sc, M, S);

    int query;
    for (query = 0; query < Q; query++) {
        int ar, ac, br, bc;
        scanf("%d %d %d %d", &ar, &ac, &br, &bc);
        printf("%d\n", colour(ar, ac, br, bc));
    }

    return 0;
}
//*/
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 344 KB Output is correct
2 Correct 99 ms 580 KB Output is correct
3 Correct 284 ms 600 KB Output is correct
4 Correct 287 ms 756 KB Output is correct
5 Incorrect 98 ms 600 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Execution timed out 3093 ms 49540 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 548 KB Output is correct
2 Runtime error 2908 ms 1048576 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 344 KB Output is correct
2 Correct 99 ms 580 KB Output is correct
3 Correct 284 ms 600 KB Output is correct
4 Correct 287 ms 756 KB Output is correct
5 Incorrect 98 ms 600 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 344 KB Output is correct
2 Correct 99 ms 580 KB Output is correct
3 Correct 284 ms 600 KB Output is correct
4 Correct 287 ms 756 KB Output is correct
5 Incorrect 98 ms 600 KB Output isn't correct
6 Halted 0 ms 0 KB -