답안 #948515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948515 2024-03-18T07:27:48 Z vjudge1 무지개나라 (APIO17_rainbow) C++17
컴파일 오류
0 ms 0 KB
#include "rainbow.h"
#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
int n,m,t,q;
int used[1005][1005];
vector< vector< int> > a;
void dfs(int x, int y, int x1, int x2, int y1, int y2){
	if(used[x][y]) return;
	if(x<x1 || x>x2 || y<y1 || y>y2 || a[x][y]) return;
	used[x][y]=1;
	dfs(x-1,y,x1,x2,y1,y2);
	dfs(x+1,y,x1,x2,y1,y2);
	dfs(x,y-1,x1,x2,y1,y2);
	dfs(x,y+1,x1,x2,y1,y2);
}
void init(int R, int C, int sr, int sc, int M, char *S) {
	n=R,m=C;
	int x=sr,y=sc;
	t=M;
	a.resize(n+1,vector<int>(m+1));
	a[x][y]=1;
	for(int i=0;i<t;i++){
		char c=S[i];
		if(c=='N') x--;
		else if(c=='S') x++;
		else if(c=='E') y++;
		else y--;
		a[x][y]=1;
	}
	
}

int colour(int ar, int ac, int br, int bc) {
    if(n==2){
	}
	else{
		int x1=ar,x2=br,y1=ac,y2=bc;
		for(int i=x1;i<=x2;i++)
			for(int j=y1;j<=y2;j++) used[i][j]=0;
		int ans=0;
		for(int i=x1;i<=x2;i++){
			for(int j=y1;j<=y2;j++){
				if(!used[i][j] && !a[i][j]){
					ans++;
					dfs(i,j,x1,x2,y1,y2);
				}
			}
		}
		return ans;
	}
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
/usr/bin/ld: /tmp/cc9sHLdQ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc7rn8GN.o:rainbow.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status