제출 #250046

#제출 시각아이디문제언어결과실행 시간메모리
250046MarcoMeijerArt Class (IOI13_artclass)C++14
7 / 100
101 ms17912 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; //macros typedef long long ll; typedef pair<int, int> ii; typedef pair<ll, ll> lll; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<ll> vll; typedef vector<lll> vlll; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define RE(a,c) REP(a,0,c) #define RE1(a,c) REP(a,1,c+1) #define REI(a,b,c) REP(a,b,c+1) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define INF 1e9 #define pb push_back #define fi first #define se second #define sz size() double c [500][500][3]; double cd[500][500][3]; int dx[]={-1,0,1,0}; int dy[]={0,1,0,-1}; int h, w; bool inside(int x, int y) {return x>=0 && x<h && y>=0 && y<w;} double examples[4][27] = { { 3.48694, 2.22775, 1.89814, 1.10229, 0.786116, 1.53039, 0.974275, 1.302, 1.86874, 2.27808, 2.46997, 2.25454, 1.76854, 1.81448, 1.66508, 0.441546, 1.33249, 2.78779, 2.56612, 2.24078, 2.96036, 0.291339, 1.45002, 2.33624, 0.695288, 1.70678, 1.6399 }, { 0.655611, 0.79869, 1.44651, 0.530874, 0.483406, 0.758347, 1.31184, 0.528795, 0.604607, 0.802128, 0.693107, 0.587086, 0.803035, 0.809455, 0.518336, 0.422567, 0.279705, 0.431132, 0.937709, 0.982469, 1.11661, 0.144054, 0.127129, 0.187791, 0.054191, 0.0399755, 0.0312532 }, { 0.416174, 0.26435, 0.22563, 1.01853, 0.753493, 0.971854, 0.694528, 0.712522, 0.799914, 0.810057, 0.761325, 0.696319, 0.753124, 0.637306, 0.522183, 0.48563, 0.503249, 0.445218, 1.12003, 0.808999, 0.520172, 0.738658, 0.56328, 0.279531, 0.189789, 0.124615, 0.0792634 }, { 0.24249, 0.0209996, 0.0622555, 0.277508, 0.139417, 0.0361746, 0.241142, 0.341452, 0.123075, 0.118788, 1.37019, 1.96754, 1.12576, 0.238768, 0.244597, 0.138623, 1.18406, 0.649754, 0.997265, 0.135162, 0.0606931, 0.406685, 0.206991, 0.054721, 0.53782, 0.545743, 0.250854 } }; int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h=H, w=W; RE(i,h) RE(j,w) c[i][j][0] = (double)R[i][j]/255.0; RE(i,h) RE(j,w) c[i][j][1] = (double)G[i][j]/255.0; RE(i,h) RE(j,w) c[i][j][2] = (double)B[i][j]/255.0; RE(x,h) RE(y,w) RE(z,3) { cd[x][y][z] = 0; RE(d,4) { int nx=x+dx[d]; int ny=y+dy[d]; if(!inside(nx,ny)) continue; double dif = (c[ny][nx][z] - c[x][y][z]); cd[x][y][z] += dif*dif; } } double values[3]; RE(z,3) { double tot=0; RE(x,h) RE(y,w) tot+=cd[x][y][z]*cd[x][y][z]; tot /= double(h*w); values[z] = tot; } int ans = 0; double closest = INF; RE(i,4) { RE(j,9) { double dist = 0.0; RE(k,3) dist += (values[k]-examples[i][j*3+k])*(values[k]-examples[i][j*3+k]); if(dist < closest) { closest = dist; ans = i; } } } return ans+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...