제출 #296671

#제출 시각아이디문제언어결과실행 시간메모리
296671williamMBDK미술 수업 (IOI13_artclass)C++14
23 / 100
102 ms6520 KiB
#include<bits/stdc++.h>
using namespace std;
#include "artclass.h"
// difference in size of components
int H, W, R[500][500], G[500][500], B[500][500];
vector<pair<int,int>> dirs = {{-1,0},{1,0},{0,-1},{0,1}};
bool isedge(pair<int,int> p1, pair<int,int> p2){
	int dr = abs(R[p1.first][p1.second] - R[p2.first][p2.second]);
	int dg = abs(G[p1.first][p1.second] - G[p2.first][p2.second]);
	int db = abs(B[p1.first][p1.second] - B[p2.first][p2.second]);
	int diff = dr * dr + dg * dg + db * db;
	return diff < 10000;
}
int style(int _H, int _W, int _R[500][500], int _G[500][500], int _B[500][500]) {
	H = _H;
	W = _W;
	int sc1 = 0, sc2 = 0, sc3 = 0, sc4 = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			R[i][j] = _R[i][j];
			G[i][j] = _G[i][j];
			B[i][j] = _B[i][j];
			sc2 += (G[i][j] > 200);
		}
	}
	vector<vector<bool>> v (H, vector<bool> (W));
	int c = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(!v[i][j]){
				int size = 0;
				queue<pair<int,int>> q;
				q.push({i,j});
				while(!q.empty()){
					auto curr = q.front(); q.pop();
					if(v[curr.first][curr.second]) continue;
					v[curr.first][curr.second] = 1;
					size++;
					for(auto dir : dirs){
						int ni = curr.first + dir.first;
						int nj = curr.second + dir.second;
						if(ni >= 0 && ni < H && nj >= 0 && nj < W && isedge(curr, {ni,nj})){
							q.push({ni, nj});
						}
					}
				}
				c += (size != 1);
			}
		}
	}
	// cout << c << endl;
	if(c < 5) return 4;
	if(c < 50) return 1;
	return 3;
}

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:17:6: warning: unused variable 'sc1' [-Wunused-variable]
   17 |  int sc1 = 0, sc2 = 0, sc3 = 0, sc4 = 0;
      |      ^~~
artclass.cpp:17:24: warning: unused variable 'sc3' [-Wunused-variable]
   17 |  int sc1 = 0, sc2 = 0, sc3 = 0, sc4 = 0;
      |                        ^~~
artclass.cpp:17:33: warning: unused variable 'sc4' [-Wunused-variable]
   17 |  int sc1 = 0, sc2 = 0, sc3 = 0, sc4 = 0;
      |                                 ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...