Submission #68619

# Submission time Handle Problem Language Result Execution time Memory
68619 2018-08-17T14:53:49 Z KLPP Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
58 ms 2924 KB
#include "rainbow.h"
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> pii;
int table[500][500];
int r,c;
void init(int R, int C, int sr, int sc, int M, char *S) {
	r=R;
	c=C;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++)table[i][j]=1;
	}
	int x,y;
	x=sr-1;
	y=sc-1;
	table[x][y]=0;
	for(int i=0;i<M;i++){
		char c=S[i];
		if(c=='N')x--;
		if(c=='S')x++;
		if(c=='E')y++;
		if(c=='W')y--;
		table[x][y]=0;
	}
	/*for(int i=0;i<r;i++){
		for(int j=0;j<c;j++)cout<<table[i][j];
		cout<<endl;
	}*/
}

int colour(int ar, int ac, int br, int bc){
	ar--;
	ac--;
	br--;
	bc--;
	bool visited[r+5][c+5];
	for(int x=ar;x<=br;x++){
		for(int y=ac;y<=bc;y++){
			visited[x][y]=false;
		}
	}
	int CC=0;
	for(int x=ar;x<=br;x++){
		for(int y=ac;y<=bc;y++){
			if(!visited[x][y] && table[x][y]){
			queue<pii>q;
			q.push(pii(x,y));
			while(!q.empty()){
				pii p=q.front();q.pop();
				if(ar<=p.first<=br && ac<=p.second<=bc && !visited[p.first][p.second] && table[p.first][p.second]){
					visited[p.first][p.second]=true;
					q.push(pii(p.first-1,p.second));
					q.push(pii(p.first+1,p.second));
					q.push(pii(p.first,p.second+1));
					q.push(pii(p.first,p.second-1));
				}
			}
			CC++;
			}
		}
	}
	return CC;
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:52:10: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
     if(ar<=p.first<=br && ac<=p.second<=bc && !visited[p.first][p.second] && table[p.first][p.second]){
        ~~^~~~~~~~~
rainbow.cpp:52:29: warning: comparisons like 'X<=Y<=Z' do not have their mathematical meaning [-Wparentheses]
     if(ar<=p.first<=br && ac<=p.second<=bc && !visited[p.first][p.second] && table[p.first][p.second]){
                           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
2 Correct 19 ms 556 KB Output is correct
3 Correct 50 ms 624 KB Output is correct
4 Correct 58 ms 672 KB Output is correct
5 Incorrect 17 ms 700 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 700 KB Output is correct
2 Incorrect 2 ms 700 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 700 KB Output is correct
2 Runtime error 22 ms 2924 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
2 Correct 19 ms 556 KB Output is correct
3 Correct 50 ms 624 KB Output is correct
4 Correct 58 ms 672 KB Output is correct
5 Incorrect 17 ms 700 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 380 KB Output is correct
2 Correct 19 ms 556 KB Output is correct
3 Correct 50 ms 624 KB Output is correct
4 Correct 58 ms 672 KB Output is correct
5 Incorrect 17 ms 700 KB Output isn't correct
6 Halted 0 ms 0 KB -