Submission #280339

#TimeUsernameProblemLanguageResultExecution timeMemory
280339shayan_p미술 수업 (IOI13_artclass)C++14
100 / 100
215 ms3664 KiB
// And you curse yourself for things you never done #include<bits/stdc++.h> #include "artclass.h" #define F first #define S second #define PB push_back #define sz(s) int((s).size()) #define bit(n,k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef double ld; const int maxn = 510, mod = 1e9 + 7, inf = 1e9 + 10; int n, m; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; bool mark[maxn][maxn]; void dfs(int x, int y, function<bool(int, int, int, int)> same){ queue<pii> q; q.push({x, y}); mark[x][y] = 1; while(sz(q)){ x = q.front().F, y = q.front().S; q.pop(); for(int i = 0; i < 4; i++){ int X = x + dx[i], Y = y + dy[i]; if(X >= 0 && Y >= 0 && X < n && Y < m && same(x, y, X, Y) && !mark[X][Y]) mark[X][Y] = 1, q.push({X, Y}); } } } int style(int n, int m, int R[500][500], int G[500][500], int B[500][500]) { ::n = n, ::m = m; auto cross = [&](int x, int y, int xx, int yy){ return R[x][y] * R[xx][yy] + G[x][y] * G[xx][yy] + B[x][y] * B[xx][yy]; }; ll sR = 0, sG = 0, sB = 0, sW = 0, sM = 0; ll green = 0; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) sR+= R[i][j], sG+= G[i][j], sB+= B[i][j], sW+= max({R[i][j], G[i][j], B[i][j]}) - min({R[i][j], G[i][j], B[i][j]}), sM+= min({R[i][j], G[i][j], B[i][j]}); double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m, WW = double(sW) / n / m, MM = double(sM) /n / m; auto calc_borders = [&](int eps){ int borders = 0; auto same = [&](int x, int y, int xx, int yy){ return abs(G[x][y] - G[xx][yy]) <= eps; // return (abs(R[x][y] - R[xx][yy]) <= eps) + (abs(G[x][y] - G[xx][yy]) <= eps) + (abs(B[x][y] - B[xx][yy]) <= eps) >= cnt; }; for(int i = 0; i < n; i++) for(int j = 0; j < m-1; j++) borders+= !same(i, j, i, j+1); for(int i = 0; i < n-1; i++) for(int j = 0; j < m; j++) borders+= !same(i, j, i+1, j); return double(borders)/n/m; }; auto calc_comp = [&](int eps){ auto same_dfs = [&](int x, int y, int xx, int yy){ return abs(G[x][y] - G[xx][yy]) <= eps; }; memset(mark, 0, sizeof mark); int comp = 0; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) if(!mark[i][j]) comp++, dfs(i, j, same_dfs); return comp; }; int TYPE1 = 0, TYPE2 = 0, TYPE3 = 0, TYPE4 = 0; if(calc_comp(10) < 100) TYPE4+= 10; else if(calc_comp(10) < 1000) TYPE1+= 10; if(calc_comp(20) > 20000) TYPE3+= 10; if(calc_comp(20) <= 15) TYPE4+= 10; if(calc_comp(30) <= 9) TYPE4+= 10; if(calc_comp(40) <= 3) TYPE4+= 10; if(calc_borders(35) >= 0.5) TYPE3+= 10; if(calc_borders(60) <= 1e-8) TYPE4+= 3; if(calc_comp(30) > 20000) TYPE3+= 10; if(WW > 105) TYPE4+= 7; if(BB >= 120) TYPE1+= 10; double num = calc_borders(10); if(0.5 <= num && num <= 0.7) TYPE2+= 8; if(0.1 <= num && num <= 0.3) TYPE1+= 4; num = calc_borders(20); if(num > 1) TYPE3+= 9; if(0.1 <= num && num <= 0.4) TYPE2+= 6; if(num > 1) TYPE3+= 7; int MX = max({TYPE1, TYPE2, TYPE3, TYPE4}); // assert(MX); // assert((MX == TYPE1) + (MX == TYPE2) + (MX == TYPE3) + (MX == TYPE4) == 1); // cout << TYPE1 << " " << TYPE2 << " " << TYPE3 << " " << TYPE4 << endl; if(MX == TYPE2) return 2; if(MX == TYPE1) return 1; if(MX == TYPE3) return 3; if(MX == TYPE4) return 4; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:45:10: warning: variable 'cross' set but not used [-Wunused-but-set-variable]
   45 |     auto cross = [&](int x, int y, int xx, int yy){
      |          ^~~~~
artclass.cpp:51:8: warning: unused variable 'green' [-Wunused-variable]
   51 |     ll green = 0;
      |        ^~~~~
artclass.cpp:55:12: warning: unused variable 'RR' [-Wunused-variable]
   55 |     double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m, WW = double(sW) / n / m, MM = double(sM) /n / m;
      |            ^~
artclass.cpp:55:35: warning: unused variable 'GG' [-Wunused-variable]
   55 |     double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m, WW = double(sW) / n / m, MM = double(sM) /n / m;
      |                                   ^~
artclass.cpp:55:106: warning: unused variable 'MM' [-Wunused-variable]
   55 |     double RR = double(sR) / n/m, GG = double(sG) / n/m, BB = double(sB) / n/m, WW = double(sW) / n / m, MM = double(sM) /n / m;
      |                                                                                                          ^~
artclass.cpp:130:1: warning: control reaches end of non-void function [-Wreturn-type]
  130 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...