제출 #301081

#제출 시각아이디문제언어결과실행 시간메모리
301081BlancaHM미술 수업 (IOI13_artclass)C++14
컴파일 에러
0 ms0 KiB
int diffValue(int H, int W, int red[500][500], int green[500][500], int blue[500][500]) {
	int ans = 0;
	for (int i = 1; i < 500; i++) {
		ans += abs(red[0][i] - red[0][i-1]);
		ans += abs(red[i][0] - red[i-1][0]);
		ans += abs(green[0][i] - green[0][i-1]);
		ans += abs(green[i][0] - green[i-1][0]);
		ans += abs(blue[0][i] - blue[0][i-1]);
		ans += abs(blue[i][0] - blue[i-1][0]);
	}
	for (int i = 1; i < 500; i++) {
		for (int j = 1; j < 500; j++) {
			ans += abs(red[i][j] - red[i][j-1]);
			ans += abs(red[i][j] - red[i-1][j]);
			ans += abs(green[i][j] - green[i][j-1]);
			ans += abs(green[i][j] - green[i-1][j]);
			ans += abs(blue[i][j] - blue[i][j-1]);
			ans += abs(blue[i][j] - blue[i-1][j]);
		}
	}
	return ans;
}

int vertValue(int H, int W, int red[500][500], int green[500][500], int blue[500][500]) {
	int ans = 0;
	for (int i = 1; i < 500; i++) {
		ans += abs(red[i][0] - red[i-1][0]);
		ans += abs(green[i][0] - green[i-1][0]);
		ans += abs(blue[i][0] - blue[i-1][0]);
	}
	for (int i = 1; i < 500; i++) {
		for (int j = 1; j < 500; j++) {
			ans += abs(red[i][j] - red[i-1][j]);
			ans += abs(green[i][j] - green[i-1][j]);
			ans += abs(blue[i][j] - blue[i-1][j]);
		}
	}
	return ans;
}

int horiValue(int H, int W, int red[500][500], int green[500][500], int blue[500][500]) {
	int ans = 0;
	for (int i = 1; i < 500; i++) {
		ans += abs(red[0][i] - red[0][i-1]);
		ans += abs(green[0][i] - green[0][i-1]);
		ans += abs(blue[0][i] - blue[0][i-1]);
	}
	for (int i = 1; i < 500; i++) {
		for (int j = 1; j < 500; j++) {
			ans += abs(red[i][j] - red[i][j-1]);
			ans += abs(green[i][j] - green[i][j-1]);
			ans += abs(blue[i][j] - blue[i][j-1]);
		}
	}
	return ans;
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
	int val = diffValue(H, W, R, G, B);
	if (val >= 25000000) return 3;
	val = horiValue(H, W, R, G, B);
	if (val >= 6500000) return 2;
	val = vertValue(H, W, R, G, B);
	if (val <= 2500000) return 1;
	else return 4;
}

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'int diffValue(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:4:10: error: 'abs' was not declared in this scope; did you mean 'ans'?
    4 |   ans += abs(red[0][i] - red[0][i-1]);
      |          ^~~
      |          ans
artclass.cpp:13:11: error: 'abs' was not declared in this scope; did you mean 'ans'?
   13 |    ans += abs(red[i][j] - red[i][j-1]);
      |           ^~~
      |           ans
artclass.cpp: In function 'int vertValue(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:27:10: error: 'abs' was not declared in this scope; did you mean 'ans'?
   27 |   ans += abs(red[i][0] - red[i-1][0]);
      |          ^~~
      |          ans
artclass.cpp:33:11: error: 'abs' was not declared in this scope; did you mean 'ans'?
   33 |    ans += abs(red[i][j] - red[i-1][j]);
      |           ^~~
      |           ans
artclass.cpp: In function 'int horiValue(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:44:10: error: 'abs' was not declared in this scope; did you mean 'ans'?
   44 |   ans += abs(red[0][i] - red[0][i-1]);
      |          ^~~
      |          ans
artclass.cpp:50:11: error: 'abs' was not declared in this scope; did you mean 'ans'?
   50 |    ans += abs(red[i][j] - red[i][j-1]);
      |           ^~~
      |           ans