Submission #1076080

#TimeUsernameProblemLanguageResultExecution timeMemory
1076080TheQuantiXArt Class (IOI13_artclass)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<float> vecs[4] = {{6.70485, 0.912805, 0.24626, 1.88986}, {1.04832, 0.782331, 0.774433, 2.08393}, {3.17105, 0.597637, 0.370123, 3.27048}, {1.11847, 2.57142, 1.29893, 0.940257}}; vector<float> vectorize(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { vector<float> ans; double r = 0, g = 0, b = 0; double cntgrey = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { // if ((R[i][j] + G[i][j] + B[i][j]) == 0) { // continue; // } r += R[i][j] / 255.; g += G[i][j] / 255.; b += B[i][j] / 255.; // r += (float)R[i][j] * 3. / (R[i][j] + G[i][j] + B[i][j]); // g += (255 * 2 + (float)G[i][j] * 2. - R[i][j] - B[i][j]) / (255. * 4); // b += (float)B[i][j] * 3. / (R[i][j] + G[i][j] + B[i][j]); } } for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (max({R[i][j], G[i][j], B[i][j]}) - min({R[i][j], G[i][j], B[i][j]}) <= 20) { cntgrey++; } } } ans.push_back(cntgrey / (H * W)); // cout << cntgrey / (H * W) << '\n'; // r /= H * W; // g /= H * W; // b /= H * W; // ans.push_back(r); // cout << r << ' ' << g << ' ' << b << '\n'; ans.push_back(abs(r - b) / (H * W)); ans.push_back(abs(g - b) / (H * W)); // ans.push_back((g - r - b) / (H * W)); // ans.push_back(b); float d = 0; for (int i = 0; i < H - 1; i++) { for (int j = 0; j < W; j++) { // if ((R[i][j] + G[i][j] + B[i][j]) == 0) { // continue; // } d += abs(R[i + 1][j] - R[i][j]) / 255.; d += abs(G[i + 1][j] - G[i][j]) / 255.; d += abs(B[i + 1][j] - B[i][j]) / 255.; } } // cout << d << endl; for (int i = 0; i < H; i++) { for (int j = 0; j < W - 1; j++) { // if ((R[i][j] + G[i][j] + B[i][j]) == 0) { // continue; // } d += abs(R[i][j + 1] - R[i][j]) / 255.; d += abs(G[i][j + 1] - G[i][j]) / 255.; d += abs(B[i][j + 1] - B[i][j]) / 255.; } } // cout << d << endl; d /= H * W * 2; ans.push_back(d); // float eq = 0; // for (int i = 0; i < H; i++) { // for (int j = 0; j < W; j++) { // // if ((R[i][j] + G[i][j] + B[i][j]) == 0) { // // continue; // // } // eq += (255. + R[i][j] - B[i][j]) / (255. * 2); // } // } // // cout << d << endl; // eq /= H * W; // ans.push_back(eq); float e = 1; for (int i = 0; i < ans.size(); i++) { e *= ans[i]; } e = sqrt(sqrt(e)); for (int i = 0; i < ans.size(); i++) { ans[i] /= e; } return ans; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { auto fl = vectorize(H, W, R, G, B); array<float, 4> diffsq = {1, 1, 1, 1}; for (int i = 0; i < 4; i++) { for (int j = 0; j < fl.size(); j++) { diffsq[i] *= (fl[j] / vecs[i][j] < 1 ? vecs[i][j] / fl[j] : fl[j] / vecs[i][j]); } } return min_element(diffsq.begin(), diffsq.end()) - diffsq.begin() + 1; }

Compilation message (stderr)

artclass.cpp: In function 'std::vector<float> vectorize(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:81:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<float>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
artclass.cpp:85:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<float>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:95:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<float>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         for (int j = 0; j < fl.size(); j++) {
      |                         ~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccLU6SJr.o: in function `main':
grader.c:(.text.startup+0x200): undefined reference to `style'
collect2: error: ld returned 1 exit status