# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
59691 | spencercompton | 미술 수업 (IOI13_artclass) | C++17 | 158 ms | 18960 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;
class Photo{
public:
vector<double> vals;
int id;
Photo(double b, double c, double d, int a){
id = a;
vals.push_back(0);
vals.push_back(+c-d-b);
vals.push_back(0);
}
double dif(Photo o){
double ret = 0.0;
for(int i = 0; i<vals.size(); i++){
// cout << "# " << vals[i] << " " << o.vals[i] << endl;
ret += (vals[i]-o.vals[i]) * (vals[i]-o.vals[i]);
}
return ret;
}
};
double dif(double x, double y){
return (x-y)/(x+y+0.0001)*2.0 * (x-y) /(x+y+0.0001) *2.0;
}
class Color{
public:
double r, g, b;
Color(){
r = 0;
g = 0;
b = 0;
}
Color(int x, int y, int z){
r = x;
g = y;
b = z;
}
bool operator<(const Color &o) const{
if(r!=o.r){
return r<o.r;
}
if(g!=o.g){
return g<o.g;
}
return b<o.b;
}
bool cool(Color o, double tol){
double val = dif(r,o.r) + dif(g,o.g) + dif(b,o.b);
// cout << "@ " << val << " " << tol << endl;
return val<=tol;
}
};
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
double sum[3] = {0.0,0.0,0.0};
vector<Color> li[H];
double all = 0.0;
double tol = 0.02;
double per = 0.0;
double black = 0.0;
double white = 0.0;
for(int i = 0; i<H; i++){
for(int j = 0; j<W; j++){
li[i].push_back(Color(R[i][j],G[i][j],B[i][j]));
if(R[i][j]>=220 && G[i][j]>=220 && B[i][j]>=220){
black++;
}
if(R[i][j]<20 && B[i][j] <20 && G[i][j]<20){
white++;
}
if(i>0){
all++;
if(li[i][j].cool(li[i-1][j],tol)){
per++;
}
}
if(j>0){
all++;
if(li[i][j].cool(li[i][j-1],tol)){
per++;
}
}
sum[0] += R[i][j];
sum[1] += G[i][j];
sum[2] += B[i][j];
}
}
per /= all;
black /= H * W;
white /= H * W;
if(white<0.00001){
assert(false);
return 4;
}
else{
// return (rand()%3) + 1;
return 2;
}
// cout << "!@# " << fixed << setprecision(6) << per << " " << black << " " << white << endl;
// if(black>0.2){
// assert(false);
// //either 1 or 3
// return 1;
// }
// else{
// return 1;
// // int x = rand()%3;
// // if(x==0){
// // return 2;
// // }
// // else if(x==1){
// // return 3;
// // }
// // else{
// // return 4;
// // }
// }
// for(int i = 0; i<3; i++){
// sum[i] /= H*W;
// }
// // cout << "bef.push_back(Photo(" << sum[0] << ", " << sum[1] << ", " << sum[2] << ", ";
// Photo now = Photo(sum[0],sum[1],sum[2],-1);
// vector<Photo> bef;
// bef.push_back(Photo(190.324, 175.007, 159.743, 1));
// bef.push_back(Photo(147.793, 137.624, 94.7409, 1));
// bef.push_back(Photo(188.825, 159.937, 143.64, 1));
// bef.push_back(Photo(173.11, 148.423, 130.601, 1));
// bef.push_back(Photo(209.025, 199.682, 197.314, 1));
// bef.push_back(Photo(229.496, 210.578, 141.905, 1));
// bef.push_back(Photo(180.467, 174.2, 178.657, 1));
// bef.push_back(Photo(169.395, 161.816, 156.893, 1));
// bef.push_back(Photo(220.232, 133.557, 122.695, 1));
// bef.push_back(Photo(130.771, 116.231, 86.0482, 2));
// bef.push_back(Photo(116.816, 108.483, 68.9826, 2));
// bef.push_back(Photo(122.273, 86.3923, 46.4901, 2));
// bef.push_back(Photo(76.5431, 86.4914, 59.5179, 2));
// bef.push_back(Photo(82.5524, 77.3391, 45.9116, 2));
// bef.push_back(Photo(111.459, 110.026, 65.8072, 2));
// bef.push_back(Photo(126.313, 103.38, 76.9841, 2));
// bef.push_back(Photo(98.2613, 103.548, 58.0462, 2));
// bef.push_back(Photo(60.6975, 91.1116, 70.2834, 2));
// bef.push_back(Photo(142.305, 134.207, 119.739, 3));
// bef.push_back(Photo(139.022, 118.038, 85.0787, 3));
// bef.push_back(Photo(143.453, 139.216, 133.429, 3));
// bef.push_back(Photo(124.075, 116.275, 102.134, 3));
// bef.push_back(Photo(131.676, 105.793, 65.2298, 3));
// bef.push_back(Photo(216.569, 201.339, 156.971, 3));
// bef.push_back(Photo(114.869, 112.627, 83.4856, 3));
// bef.push_back(Photo(119.47, 113.515, 98.8594, 3));
// bef.push_back(Photo(133.837, 115.121, 118.349, 3));
// bef.push_back(Photo(100.719, 110.242, 119.565, 4));
// bef.push_back(Photo(84.5105, 23.8112, 25.2976, 4));
// bef.push_back(Photo(217.14, 6.45131, 14.198, 4));
// bef.push_back(Photo(239.767, 156.768, 89.0347, 4));
// bef.push_back(Photo(155.385, 76.7555, 39.738, 4));
// bef.push_back(Photo(195.063, 118.751, 25.1931, 4));
// bef.push_back(Photo(46.4144, 48.1066, 50.294, 4));
// bef.push_back(Photo(182.285, 104.388, 75.9469, 4));
// bef.push_back(Photo(201.687, 162.679, 58.5665, 4));
// double tot[5] = {0.0,0.0,0.0,0.0,0.0};
// int best = 1;
// for(int i = 0; i<bef.size(); i++){
// tot[bef[i].id] += bef[i].dif(now);
// }
// for(int i = 2; i<=4; i++){
// if(tot[i]<tot[best]){
// best = i;
// }
// }
// return best;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |