제출 #59713

#제출 시각아이디문제언어결과실행 시간메모리
59713spencercompton미술 수업 (IOI13_artclass)C++17
컴파일 에러
0 ms0 KiB
//also not my code, I think this judge is broken #include <bits/stdc++.h> using namespace std; typedef long long LL; const double PI = 4 * atan(1); #define MAXN 503 int N, M; int R[MAXN][MAXN], G[MAXN][MAXN], B[MAXN][MAXN], W[MAXN][MAXN]; const vector<vector<double> > samples = { {132.968, 121.349, 118.288, 11.4407, 77.0857, 77.6033, 76.5226}, {180.467, 174.2, 178.657, 13.66, 89.3161, 85.3534, 91.1893}, {173.11, 148.423, 130.601, 15.893, 85.8861, 93.3106, 98.8468}, {138.609, 131.427, 128.751, 9.39652, 57.0097, 52.7232, 53.4372}, {77.7001, 79.9646, 53.4635, 27.1064, 58.6349, 58.5749, 56.2765}, {102.289, 95.6886, 66.0251, 24.476, 54.1985, 58.2039, 60.4734}, {104.84, 102.169, 45.1182, 28.2966, 41.251, 47.0644, 33.171}, {96.0905, 90.0843, 56.3745, 18.9765, 65.0692, 65.1562, 59.7448}, {94.3703, 77.7906, 61.5299, 82.127, 47.868, 46.1825, 37.9178}, {82.3594, 72.4792, 66.1918, 88.3599, 51.9845, 48.8226, 46.9973}, {122.441, 111.481, 83.5336, 81.3022, 62.9915, 59.4681, 51.4485}, {143.453, 139.216, 133.429, 98.5458, 69.4803, 69.4191, 68.0384}, {239.767, 156.768, 89.0347, 6.45365, 16.7747, 90.2051, 95.6333}, {145.821, 150.718, 94.9484, 5.21068, 58.0489, 38.3001, 68.5446}, {123.497, 98.8349, 34.2718, 6.28276, 77.1566, 70.1218, 22.5618}, {225.533, 134.059, 4.12236, 5.31505, 12.4194, 53.9867, 9.77561} }; const vector<double> weights = { 1.0, 1.0, 1.0, 100.0, 1.0, 1.0, 1.0 }; inline int getR(int RGB) { return (RGB >> 16) & 0xFF; } inline int getG(int RGB) { return (RGB >> 8) & 0xFF; } inline int getB(int RGB) { return RGB & 0xFF; } vector<double> getAvg() { double r = 0, g = 0, b = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { r += R[i][j]; g += G[i][j]; b += B[i][j]; } } return {r / (N * M), g / (N * M), b / (N * M)}; } vector<double> getStdDev() { double rr, gg, bb; auto v = getAvg(); rr = v[0], gg = v[1], bb = v[2]; double r = 0, g = 0, b = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { r += pow(R[i][j] - rr, 2); g += pow(G[i][j] - gg, 2); b += pow(B[i][j] - bb, 2); } } return {sqrt(r / (N * M)), sqrt(g / (N * M)), sqrt(b / (N * M))}; } double cscore() { double total = 0; int num = 0; for (int i = 1; i < N - 1; i++) { for (int j = 1; j < M - 1; j++) { total += abs(4 * W[i][j] - (W[i-1][j] + W[i+1][j] + W[i][j-1] + W[i][j+1])); ++num; } } return total / num; } vector<double> getFeatures() { vector<double> v; for (auto d : getAvg()) v.push_back(d); v.push_back(cscore()); for (auto d : getStdDev()) v.push_back(d); return v; } double dist(vector<double> v, vector<double> u) { double x = 0; for (int i = 0; i < v.size(); i++) { x += weights[i] * pow(v[i] - u[i], 2); } return sqrt(x); } int classify() { auto v = getFeatures(); double best = numeric_limits<double>::infinity(); int cls = -1; for (int i = 0; i < samples.size(); i++) { double d = dist(v, samples[i]); if (d < best) { best = d; cls = i / 4; } } return cls + 1; } int classify2() { auto v = getFeatures(); double best = numeric_limits<double>::infinity(); int cls = -1; for (int i = 0; i < samples.size(); i += 4) { vector<double> ans; for (int j = i; j < i + 4; j++) ans.push_back(dist(v, samples[j])); sort(ans.begin(), ans.end()); double total = ans[0] + ans[1]; if (total < best) { best = total; cls = i / 4; } } return cls + 1; } void printFeatures() { auto v = getFeatures(); cout << '{'; bool first = true; for (double d : v) { if (!first) cout << ", "; first = false; cout << d; } cout << '}' << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); #ifndef DEV int T; cin >> T; while (T--) { #endif cin >> N >> M; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { int rgb; cin >> rgb; R[i][j] = getR(rgb); G[i][j] = getG(rgb); B[i][j] = getB(rgb); W[i][j] = (R[i][j] + G[i][j] + B[i][j]) / 3; } } // printFeatures(); cout << classify2() << '\n'; #ifndef DEV } #endif cout.flush(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'double dist(std::vector<double>, std::vector<double>)':
artclass.cpp:92:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < v.size(); i++) {
                     ~~^~~~~~~~~~
artclass.cpp: In function 'int classify()':
artclass.cpp:102:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < samples.size(); i++) {
                     ~~^~~~~~~~~~~~~~~~
artclass.cpp: In function 'int classify2()':
artclass.cpp:116:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < samples.size(); i += 4) {
                     ~~^~~~~~~~~~~~~~~~
/tmp/ccSqKtEQ.o: In function `main':
artclass.cpp:(.text.startup+0x3e0): multiple definition of `main'
/tmp/ccwUnhBE.o:grader.c:(.text.startup+0x0): first defined here
/tmp/ccwUnhBE.o: In function `main':
grader.c:(.text.startup+0x21a): undefined reference to `style'
collect2: error: ld returned 1 exit status