Submission #1035804

#TimeUsernameProblemLanguageResultExecution timeMemory
1035804c2zi6Art Class (IOI13_artclass)C++14
93 / 100
54 ms9156 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "artclass.h" struct PIXEL { int r, g, b; }; typedef vector<PIXEL> VPIXEL; typedef vector<VPIXEL> VVPIXEL; bool similar(const PIXEL& a, const PIXEL& b, int maxdist = 80) { int dr = abs(a.r - b.r); int dg = abs(a.g - b.g); int db = abs(a.b - b.b); int dist = sqrt(dr*dr + dg*dg + db*db); return dist <= maxdist; } bool isgreen(const PIXEL& a) { bool ret = false; ret |= similar(a, {0, 255, 0}, 200); ret |= similar(a, {0, 100, 0}, 50); return ret; } int n, m; VVPIXEL image; VPI harevan(int i, int j) { VPI ret; VVPIXEL& a = image; if (i > 0 && j > 0) ret.pb({i-1, j-1}); if (i > 0) ret.pb({i-1, j}); if (i > 0 && j < m-1) ret.pb({i-1, j+1}); if (j > 0) ret.pb({i, j-1}); if (j < m-1) ret.pb({i, j+1}); if (i < n-1 && j > 0) ret.pb({i+1, j-1}); if (i < n-1) ret.pb({i+1, j}); if (i < n-1 && j < m-1) ret.pb({i+1, j+1}); return ret; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { n = H; m = W; image = VVPIXEL(n, VPIXEL(m)); rep(i, n) rep(j, m) image[i][j] = PIXEL{R[i][j], G[i][j], B[i][j]}; int dif = 0; int grn = 0; rep(i, n) rep(j, m) { if (i) dif += !similar(image[i][j], image[i-1][j]); if (j) dif += !similar(image[i][j], image[i][j-1]); grn += isgreen(image[i][j]); } int diff = (ld)dif / (H * W) * 100; int green = (ld)grn / (H * W) * 100; /*cout << " diff:\t" << diff << ", green:\t" << green << endl;*/ if (green >= 7 && green > diff) return 2; if (diff >= 11) return 3; if (diff >= 2 && green <= 7) return 1; if (green >= 15) return 2; return 4; return -1; }

Compilation message (stderr)

artclass.cpp: In function 'VPI harevan(int, int)':
artclass.cpp:60:14: warning: unused variable 'a' [-Wunused-variable]
   60 |     VVPIXEL& a = image;
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...