답안 #73435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73435 2018-08-28T09:14:19 Z FedericoS 무지개나라 (APIO17_rainbow) C++14
0 / 100
3000 ms 28540 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();
					V[p.first][p.second]=true;
					Q.pop();

					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 12 ms 376 KB Output is correct
2 Execution timed out 3030 ms 28540 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 28540 KB Output is correct
2 Correct 3 ms 28540 KB Output is correct
3 Runtime error 3 ms 28540 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 28540 KB Output is correct
2 Runtime error 4 ms 28540 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 376 KB Output is correct
2 Execution timed out 3030 ms 28540 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 376 KB Output is correct
2 Execution timed out 3030 ms 28540 KB Time limit exceeded
3 Halted 0 ms 0 KB -