답안 #73438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73438 2018-08-28T09:16:23 Z FedericoS 무지개나라 (APIO17_rainbow) C++14
11 / 100
41 ms 1544 KB
#include <iostream>
#include <queue>
#include "rainbow.h"
using namespace std;

bool B[55][55];
bool V[55][55];
int R,C;
int rmov[]={1,-1,0,0};
int cmov[]={0,0,1,-1};
queue<pair<int,int>> Q;

void init(int R_, int C_, int sr, int sc, int M, char *S) {

	R=R_;
	C=C_;

	sr--;
	sc--;

	B[sr][sc]=true;

	for(int i=0;i<M;i++){

		if(S[i]=='S')
			sr++;
		if(S[i]=='N')
			sr--;
		if(S[i]=='E')
			sc++;
		if(S[i]=='W')
			sc--;

		B[sr][sc]=true;
	}
/*
	for(int i=0;i<R;i++){
		for(int j=0;j<C;j++)
			cout<<B[i][j];
		cout<<endl;
	}
*/
}

int colour(int ar, int ac, int br, int bc) {

	ar--;
	ac--;
	br--;
	bc--;
	int ans=0;

	for(int i=0;i<R;i++)
		for(int j=0;j<C;j++)
			V[i][j]=B[i][j];


	for(int i=ar;i<=br;i++)
		for(int j=ac;j<=bc;j++)
			if(!V[i][j]){

				ans++;
				while(Q.size())
					Q.pop();
				Q.push({i,j});

				while(Q.size()){

					pair<int,int> p=Q.front();
					Q.pop();
					if(V[p.first][p.second])
						continue;
					V[p.first][p.second]=true;

					for(int m=0;m<4;m++)
						if(!V[p.first+rmov[m]][p.second+cmov[m]] and ar<=p.first+rmov[m] and p.first+rmov[m]<=br and ac<=p.second+cmov[m] and p.second+cmov[m]<=bc)
							Q.push({p.first+rmov[m],p.second+cmov[m]});
						
				}
				
			}

    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 15 ms 356 KB Output is correct
3 Correct 41 ms 540 KB Output is correct
4 Correct 35 ms 696 KB Output is correct
5 Correct 17 ms 720 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 4 ms 756 KB Output is correct
8 Correct 3 ms 804 KB Output is correct
9 Correct 3 ms 808 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 33 ms 904 KB Output is correct
12 Correct 27 ms 1032 KB Output is correct
13 Correct 18 ms 1032 KB Output is correct
14 Correct 14 ms 1032 KB Output is correct
15 Correct 3 ms 1032 KB Output is correct
16 Correct 3 ms 1032 KB Output is correct
17 Correct 3 ms 1032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1032 KB Output is correct
2 Correct 3 ms 1032 KB Output is correct
3 Runtime error 5 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1032 KB Output is correct
2 Runtime error 5 ms 1288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 15 ms 356 KB Output is correct
3 Correct 41 ms 540 KB Output is correct
4 Correct 35 ms 696 KB Output is correct
5 Correct 17 ms 720 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 4 ms 756 KB Output is correct
8 Correct 3 ms 804 KB Output is correct
9 Correct 3 ms 808 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 33 ms 904 KB Output is correct
12 Correct 27 ms 1032 KB Output is correct
13 Correct 18 ms 1032 KB Output is correct
14 Correct 14 ms 1032 KB Output is correct
15 Correct 3 ms 1032 KB Output is correct
16 Correct 3 ms 1032 KB Output is correct
17 Correct 3 ms 1032 KB Output is correct
18 Runtime error 4 ms 1544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 248 KB Output is correct
2 Correct 15 ms 356 KB Output is correct
3 Correct 41 ms 540 KB Output is correct
4 Correct 35 ms 696 KB Output is correct
5 Correct 17 ms 720 KB Output is correct
6 Correct 2 ms 752 KB Output is correct
7 Correct 4 ms 756 KB Output is correct
8 Correct 3 ms 804 KB Output is correct
9 Correct 3 ms 808 KB Output is correct
10 Correct 3 ms 868 KB Output is correct
11 Correct 33 ms 904 KB Output is correct
12 Correct 27 ms 1032 KB Output is correct
13 Correct 18 ms 1032 KB Output is correct
14 Correct 14 ms 1032 KB Output is correct
15 Correct 3 ms 1032 KB Output is correct
16 Correct 3 ms 1032 KB Output is correct
17 Correct 3 ms 1032 KB Output is correct
18 Runtime error 4 ms 1544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -