Submission #575812

#TimeUsernameProblemLanguageResultExecution timeMemory
575812BelguteiArt Class (IOI13_artclass)C++17
18 / 100
57 ms3256 KiB
#include "artclass.h" #include <bits/stdc++.h> #define ll long long #define pb push_back #define pp pop_back #define mp make_pair #define bb back #define ff first #define ss second using namespace std; bool inbound(pair<int, int> now, int H, int W) { if (now.ff < 0 || now.ff >= H) return 0; if (now.ss < 0 || now.ss >= W) return 0; return 1; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { pair<int, int> dir[4] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}; long long avr = 0, avg = 0, avb = 0, avdisp = 0, now, cnt, total = 0; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { avr += R[i][j]; avg += G[i][j]; avb += B[i][j]; now = 0, cnt = 0; for (int k = 0; k < 4; k++) { if (!inbound({i+dir[k].ff, j+dir[k].ss}, H, W)) continue; cnt++; now += abs(R[i][j]-R[i+dir[k].ff][j+dir[k].ss]); now += abs(G[i][j]-G[i+dir[k].ff][j+dir[k].ss]); now += abs(B[i][j]-B[i+dir[k].ff][j+dir[k].ss]); } if (cnt) { now /= cnt*3; if (now > 40) avdisp++; } } if (avdisp) avdisp = H*W/avdisp; avr /= (H*W); avg /= (H*W); avb /= (H*W); // cout << avr << ' ' << avg << ' ' << avb << ' ' << avdisp << '\n'; if (avdisp < 40 && avdisp >= 5) return 1; if (avdisp < 5) return 3; if (avdisp > 500) return 4; if (abs(avg-avb)+abs(avr-avb) > 50) return 2; return 1; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:21:64: warning: unused variable 'total' [-Wunused-variable]
   21 |     long long avr = 0, avg = 0, avb = 0, avdisp = 0, now, cnt, total = 0;
      |                                                                ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...