제출 #155912

#제출 시각아이디문제언어결과실행 시간메모리
155912qkxwsm미술 수업 (IOI13_artclass)C++14
16 / 100
83 ms10912 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef pair<ld, ld> pdd; typedef vector<vector<array<int, 3> > > img; int ans; img grid; pdd vals[4] = {{2881.44, 0.0}, {6595.89, 0.0}, {7891.44, 0.0}, {2518.33, 0.0}}; pdd calc(img f) { //amount of black? //number of distinct colors? pdd res = {0, 0}; set<array<int, 3> > s; FOR(i, 0, 100) { FOR(j, 0, 100) { array<int, 3> cur = f[i][j]; // FOR(k, 0, 3) cur[i] /= 10; s.insert(cur); } } res.fi = SZ(s); return res; } ld dist(pdd a, pdd b) { return (a.fi - b.fi) * (a.fi - b.fi) + (a.se - b.se) * (a.se - b.se); } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { //calculate some quantity of grid.resize(H); FOR(i, 0, H) { grid[i].resize(W); FOR(j, 0, W) { grid[i][j][0] = R[i][j]; grid[i][j][1] = G[i][j]; grid[i][j][2] = B[i][j]; } } auto cur = calc(grid); ans = 0; FOR(i, 1, 4) { if (dist(cur, vals[i]) < dist(cur, vals[ans])) { ans = i; } } return ans + 1; //calculate the minimum }
#Verdict Execution timeMemoryGrader output
Fetching results...