Submission #1075574

#TimeUsernameProblemLanguageResultExecution timeMemory
1075574TheQuantiXArt Class (IOI13_artclass)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

vector<float> vecs[4] = {{0.707344, 0.363771, 0.543803}, {0.994021, 0.989584, 0.00129563}, {1.02652, 0.767299, 0.00728856}, {0.995276, 0.500576, 0.0165025}};

vector<float> vectorize(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    vector<float> ans;
    float r = 0, g = 0, b = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            r += R[i][j] * 3 / (R[i][j] + G[i][j] + B[i][j]);
            g += G[i][j] * 3 / (R[i][j] + G[i][j] + B[i][j]);
            b += B[i][j] * 3 / (R[i][j] + G[i][j] + B[i][j]);
        }
    }
    r /= H * W;
    g /= H * W;
    b /= H * W;
    ans.push_back(r);
    ans.push_back(g);
    ans.push_back(b);
    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 = {0, 0, 0, 0};
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < fl.size(); j++) {
            diffsq[i] += (fl[j] - vecs[i][j]) * (fl[j] - vecs[i][j]);
        }
    }
    return min_element(diffsq.begin(), diffsq.end()) - diffsq.begin() + 1;
}

Compilation message (stderr)

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