제출 #240254

#제출 시각아이디문제언어결과실행 시간메모리
240254Nightlight미술 수업 (IOI13_artclass)C++14
컴파일 에러
0 ms0 KiB
#include "artclass.h" #include <bits/stdc++.h> #define isg(a, b) ((G[a][b] - R[a][b] > tolG && G[a][b] - B[a][b] > tolG)) #define pii pair<int, int> using namespace std; const int tolG = 20; const int tol = 20; int N, M; int R[505][505]; int G[505][505]; int B[505][505]; set<long long> ada; int green, white, big_green; int baru, cnt_diff, beda; double avg_diff;//avg diff of color under tol double avg_pos_white;//avg ketinggian putih bool ijo(int a, int b) { return ((G[a][b] - R[a][b] > tolG && G[a][b] - B[a][b] > tolG)); } bool putih(int a, int b) { int mx = max(G[a][b], max(R[a][b], B[a][b])); int mn = min(G[a][b], min(R[a][b], B[a][b])); return mx - mn <= 5; } int perbedaan(int a, int b, int c, int d) { return abs(R[a][b] - R[c][d]) + abs(B[a][b] - B[c][d]) + abs(G[a][b] - G[c][d]); } int vis[505][505]; pii par[505][505]; int sz[505][505]; pii findpar(pii u) { return par[u.first][u.second] == u ? u : par[u.first][u.second] = findpar(par[u.first][u.second]); } void merge(int a, int b, int p, int q) { pii u = {a, b}, v = {p, q}; u = findpar(u), v = findpar(v); if(v == u) return; // cout << a << " " << b << " - " << p << " " << q << "\n"; par[v.first][v.second] = u; } void go(int r, int c) { if(r > 1) { int tmp = beda(r, c, r - 1, c); if(beda <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r - 1, c); } } if(r < N) { int tmp = beda(r, c, r + 1, c); if(beda <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r + 1, c); } } if(c > 1) { int tmp = beda(r, c, r, c - 1); if(beda <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r, c - 1); } } if(c < N) { int tmp = beda(r, c, r, c + 1); if(beda <= tol) { avg_diff += beda; cnt_diff++; merge(r, c, r, c + 1); } } } int style(int H, int W, int r[500][500], int g[500][500], int b[500][500]) { N = H, M = W; for(int i = 1; i <= H; i++) { for(int j = 1; j <= W; j++) { R[i][j] = r[i - 1][j - 1]; G[i][j] = g[i - 1][j - 1]; B[i][j] = b[i - 1][j - 1]; } } for(int i = 1; i <= H; i++) { for(int j = 1; j <= W; j++) { green += ijo(i, j); if(putih(i, j)) { avg_pos_white += i; putih++; } long long skrg = 1000000000 * R[i][j] + 1000 * G[i][j] + B[i][j]; if(ada.count(skrg)) beda++; else ada.insert(skrg); go(i, j); } } avg_diff /= cnt_diff; if(avg_diff <= 1.0) { //petak2 return 1; } if(avg_diff <= 5.0) { return 4; } if(green > H * W / 4) { return 2; } return 3; }

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

artclass.cpp: In function 'void go(int, int)':
artclass.cpp:52:38: error: 'beda' cannot be used as a function
         int tmp = beda(r, c, r - 1, c);
                                      ^
artclass.cpp:52:13: warning: unused variable 'tmp' [-Wunused-variable]
         int tmp = beda(r, c, r - 1, c);
             ^~~
artclass.cpp:60:38: error: 'beda' cannot be used as a function
         int tmp = beda(r, c, r + 1, c);
                                      ^
artclass.cpp:60:13: warning: unused variable 'tmp' [-Wunused-variable]
         int tmp = beda(r, c, r + 1, c);
             ^~~
artclass.cpp:68:38: error: 'beda' cannot be used as a function
         int tmp = beda(r, c, r, c - 1);
                                      ^
artclass.cpp:68:13: warning: unused variable 'tmp' [-Wunused-variable]
         int tmp = beda(r, c, r, c - 1);
             ^~~
artclass.cpp:76:38: error: 'beda' cannot be used as a function
         int tmp = beda(r, c, r, c + 1);
                                      ^
artclass.cpp:76:13: warning: unused variable 'tmp' [-Wunused-variable]
         int tmp = beda(r, c, r, c + 1);
             ^~~
artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:99:22: warning: ISO C++ forbids incrementing a pointer of type 'bool (*)(int, int)' [-Wpointer-arith]
                 putih++;
                      ^~
artclass.cpp:99:22: error: lvalue required as increment operand