Submission #59624

#TimeUsernameProblemLanguageResultExecution timeMemory
59624spencercomptonArt Class (IOI13_artclass)C++17
0 / 100
177 ms6832 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; class Color{ public: int r, g, b; 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, int tol){ int 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]) { vector<Color> li; double gsum = 0.0; double asum = 0.0; for(int i = 0; i<H; i++){ for(int j = 0; j<W; j++){ li.push_back(Color(R[i][j],G[i][j],B[i][j])); if(G[i][j] >=R[i][j] && G[i][j]>=B[i][j]){ gsum++; } asum++; } } double rat = gsum/asum; int tol = 5000; int cnt = 0; sort(li.begin(),li.end()); for(int i = 0; i<li.size(); i++){ bool nex = true; for(int j = max(0,i-500); j<i && nex; j++){ nex &= !li[i].cool(li[j],tol); } for(int j =0; nex && i>0 && j<400; j++){ int ind = rand()%i; nex &= !li[i].cool(li[ind],tol); } if(nex){ cnt++; } } if(rat>=0.70){ return 2; } if(cnt>=40){ return 1; } if(cnt<=6){ return 4; } return 3; // cout << cnt << " " << rat << endl; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:45:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i<li.size(); i++){
                 ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...