Submission #59634

#TimeUsernameProblemLanguageResultExecution timeMemory
59634spencercomptonArt Class (IOI13_artclass)C++17
0 / 100
1269 ms39232 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; 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]) { vector<Color> li; double gsum = 0.0; double asum = 0.0; // cout << "J " << endl; vector<Color> cc[H]; // cout << "G " << endl; 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])); cc[i].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++; } } // cout << "F" << endl; double rat = gsum/asum; // int tol = 5000; // double tol = 0.00003; double tol = 0.00005; 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-100); j<i && nex; j++){ nex &= !li[i].cool(li[j],tol); } for(int j =0; nex && i>0 && j<100; j++){ int ind = rand()%i; nex &= !li[i].cool(li[ind],tol); } if(nex){ cnt++; } } // cout << cnt << " " << rat << endl; int cnt2 = 0; bool v[H][W]; for(int i = 0; i<H; i++){ for(int j = 0; j<W; j++){ v[i][j] = false; } } vector<int> dx; vector<int> dy; for(int i = -10; i<=10; i++){ for(int j = -10; j<=10; j++){ if(abs(i)+abs(j)>=4){ continue; } dy.push_back(i); dx.push_back(j); } } vector<int> all; int mini = 4000; for(int i = 0; i<H; i++){ for(int j = 0; j<W; j++){ if(v[i][j]){ continue; } cnt2++; vector<pair<int, int> > q; v[i][j] = true; q.push_back(make_pair(i,j)); for(int k = 0; k<q.size(); k++){ for(int a = 0; a<dy.size(); a++){ int ny = q[k].first + dy[a]; int nx = q[k].second + dx[a]; if(ny>=0 && ny<H && nx>=0 && nx<W && !v[ny][nx] && cc[q[k].first][q[k].second].cool(cc[ny][nx],tol)){ v[ny][nx] = true; q.push_back(make_pair(ny,nx)); } } } if(q.size()<=1000){ cnt2--; } // cout << all.push_back(q.size()); } } sort(all.begin(),all.end()); // for(int i = 0; i<all.size(); i++){ // cout << all[i] << endl; // } // cout << "! " << cnt2 << endl; double prop = (double)all[all.size()-1] / (double)(H*W); double prop2 = 0.0; for(int i = 1; i<=4 && i<=all.size(); i++){ prop2 += all[all.size()-i]; } prop2 /= (double)(H*W); // cout << "Z" << all[all.size()-1] << endl; // cout << "@ " << prop << " " << prop2 << endl; if(rat>=0.5){ return 2; } assert(false); // if(prop2>=0.80){ // return 4; // } // else if(prop2 <=0.15){ // return 1; // } // else if(prop2>=0.45){ // return 3; // } return 2; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:61:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i<li.size(); i++){
                 ~^~~~~~~~~~
artclass.cpp:104:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k = 0; k<q.size(); k++){
                   ~^~~~~~~~~
artclass.cpp:105:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int a = 0; a<dy.size(); a++){
                    ~^~~~~~~~~~
artclass.cpp:128:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1; i<=4 && i<=all.size(); i++){
                         ~^~~~~~~~~~~~
artclass.cpp:94:6: warning: unused variable 'mini' [-Wunused-variable]
  int mini = 4000;
      ^~~~
artclass.cpp:126:9: warning: unused variable 'prop' [-Wunused-variable]
  double prop = (double)all[all.size()-1] / (double)(H*W);
         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...