답안 #948901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948901 2024-03-18T16:03:54 Z vjudge1 무지개나라 (APIO17_rainbow) C++17
11 / 100
12 ms 604 KB
#include <bits/stdc++.h>
#include "rainbow.h"
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a: b)
#define pii pair<int, int>
#define fi first
#define se second

using namespace std;

bool river[55][55]{};

void init(int R, int C, int sr, int sc, int M, char *S){
	if(R>50 || C>50) exit(0);
	river[sr][sc]=true;
	rep(i,0,M){
		if(S[i]=='N') sr--;
		else if(S[i]=='S') sr++;
		else if(S[i]=='W') sc--;
		else sc++;
		river[sr][sc]=true;
	}
}

int colour(int ar, int ac, int br, int bc){
	bool vis[55][55]{};
	int c=0;
	rep(i,ar,br+1){
		rep(j,ac,bc+1){
			int x=i, y=j;
			if(vis[x][y] || river[x][y]) continue;
			c++;
			queue<pii> q;
			q.push({x,y});
			vis[x][y]=true;
			while(q.size()){
				x=q.front().fi;
				y=q.front().se;
				q.pop();
				if(x+1<=br && !vis[x+1][y] && !river[x+1][y]) vis[x+1][y]=true, q.push({x+1,y});
				if(x-1>=ar && !vis[x-1][y] && !river[x-1][y]) vis[x-1][y]=true, q.push({x-1,y});
				if(y+1<=bc && !vis[x][y+1] && !river[x][y+1]) vis[x][y+1]=true, q.push({x,y+1});
				if(y-1>=ac && !vis[x][y-1] && !river[x][y-1]) vis[x][y-1]=true, q.push({x,y-1});
			}
		}
	}
	return c;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 12 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 7 ms 348 KB Output is correct
14 Correct 8 ms 480 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 12 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 7 ms 348 KB Output is correct
14 Correct 8 ms 480 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 1 ms 604 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 12 ms 348 KB Output is correct
4 Correct 10 ms 348 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 9 ms 348 KB Output is correct
12 Correct 8 ms 348 KB Output is correct
13 Correct 7 ms 348 KB Output is correct
14 Correct 8 ms 480 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 1 ms 604 KB Output isn't correct
19 Halted 0 ms 0 KB -