제출 #296660

#제출 시각아이디문제언어결과실행 시간메모리
296660williamMBDK미술 수업 (IOI13_artclass)C++14
4 / 100
98 ms9116 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 + dg + db; return diff < 200; } int style(int _H, int _W, int _R[500][500], int _G[500][500], int _B[500][500]) { H = _H; W = _W; 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]; } } 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]){ 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; 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++; } } } // cout << c << endl; if(c < 2) return 2; else if(c < 5) return 4; else if(c < 50) return 1; return 3; }
#Verdict Execution timeMemoryGrader output
Fetching results...