제출 #532233

#제출 시각아이디문제언어결과실행 시간메모리
532233TheWilp미술 수업 (IOI13_artclass)C++14
6 / 100
78 ms14120 KiB
#include "artclass.h" #include <iostream> #include <vector> class name { public: name(int a, int b) { x = a; y = b; } int x; int y; }; bool macth(const std::vector<std::vector<std::vector<int>>>& p1, int i1, int j1, int i2, int j2) { return (p1[0][i1][j1] == p1[0][i2][j2]) && (p1[1][i1][j1] == p1[1][i2][j2]) && (p1[2][i1][j1] == p1[2][i2][j2]); } int Ge(int a,int g) { a /= g; return a; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { double style1 = 0; double style2 = 0; double style3 = 0; double style4 = 0; // style2 int s2[3]; const int generalize1 = 1; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { s2[0] = Ge(R[i][j], generalize1); s2[1] = Ge(G[i][j], generalize1); s2[2] = Ge(B[i][j], generalize1); if (s2[1] > s2[2] * 1.2) style2++; } } // else std::vector<std::vector<std::vector<int>>> s1(3, std::vector<std::vector<int>>(500, std::vector<int>(500))); const int generalize2 = 64; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { s1[0][i][j] = Ge(R[i][j], generalize2); s1[1][i][j] = Ge(G[i][j], generalize2); s1[2][i][j] = Ge(B[i][j], generalize2); } } std::vector<std::vector<int>> s(500, std::vector<int>(500)); for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { s[i][j] = 0; } } int block = 0; std::vector<name> v; int i = 0; for (int q = 0; q < H; q++) { for (int w = 0; w < W; w++) { while (i != v.size()) { int x = v[i].x; int y = v[i].y; if (x != 0) { if (s[x - 1][y] == 0 && macth(s1,x,y,x - 1,y)) { v.push_back(name(x - 1, y)); s[x - 1][y] = 1; } } if (x != H - 1) { if (s[x + 1][y] == 0 && macth(s1, x, y, x + 1, y)) { v.push_back(name(x + 1, y)); s[x + 1][y] = 1; } } if (y != 0){ if (s[x][y - 1] == 0 && macth(s1, x, y, x, y - 1)) { v.push_back(name(x, y - 1)); s[x][y - 1] = 1; } } if (y != W - 1) { if (s[x][y + 1] == 0 && macth(s1, x, y, x, y + 1)) { v.push_back(name(x, y + 1)); s[x][y + 1] = 1; } } ++i; } if (s[q][w] == 0) { v.push_back(name(q,w)); ++block; } } } // std::cout << style2 << " " << block << std::endl;; if (style2 >= 60 * H * W / 100) return 2; if (block <= 6) return 4; if (block <= 100) return 1; else return 4; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:62:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<name>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             while (i != v.size()) {
      |                    ~~^~~~~~~~~~~
artclass.cpp:21:12: warning: unused variable 'style1' [-Wunused-variable]
   21 |     double style1 = 0;
      |            ^~~~~~
artclass.cpp:23:12: warning: unused variable 'style3' [-Wunused-variable]
   23 |     double style3 = 0;
      |            ^~~~~~
artclass.cpp:24:12: warning: unused variable 'style4' [-Wunused-variable]
   24 |     double style4 = 0;
      |            ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...