Submission #59660

#TimeUsernameProblemLanguageResultExecution timeMemory
59660spencercomptonArt Class (IOI13_artclass)C++17
29 / 100
120 ms3672 KiB
#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(b); vals.push_back(c); vals.push_back(d); } 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; } }; class Color{ public: double r, g, b; Color(){ r = 0; g = 0; b = 0; } Color(int x, int y, int z){ double tot = x+y+z; r = x; r/= tot; g = y; g/= tot; b = z; b /= tot; } 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 = (r-o.r) * (r-o.r) + (g-o.g) * (g-o.g)+ (b-o.b) * (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}; for(int i = 0; i<H; i++){ for(int j = 0; j<W; j++){ sum[0] += R[i][j]; sum[1] += G[i][j]; sum[2] += B[i][j]; } } 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 = 0; for(int i = 1; i<bef.size(); i++){ if(bef[i].dif(now) < bef[best].dif(now)){ best = i; } } return bef[best].id; }

Compilation message (stderr)

artclass.cpp: In member function 'double Photo::dif(Photo)':
artclass.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i<vals.size(); i++){
                  ~^~~~~~~~~~~~
artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:112:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i<bef.size(); i++){
                 ~^~~~~~~~~~~
artclass.cpp:109:9: warning: unused variable 'tot' [-Wunused-variable]
  double tot[5] = {0.0,0.0,0.0,0.0,0.0};
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...