제출 #1023982

#제출 시각아이디문제언어결과실행 시간메모리
1023982dozer미술 수업 (IOI13_artclass)C++14
43 / 100
148 ms17236 KiB
    #include <bits/stdc++.h>
    #include "artclass.h"
    using namespace std;
    #define sp " "
    #define endl "\n"
    #define pb push_back
    #define pii pair<int, int>
    #define st first
    #define nd second
    #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
    #define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
    #define mid (l + r) / 2
    #define LL node * 2
    #define RR node * 2 + 1
    #define ll long long
    #define MAXN 300005
    #define M 501
     
    const int modulo = 1e9 + 7;
    const ll INF = 2e18 + 7;
     
     
    static int DIM[2];
    static int R[500][500];
    static int G[500][500];
    static int B[500][500];
     
     
    int par[MAXN], sz[MAXN];
    int h, w;
    set<int> roots;
     
    int find(int node){
        if (par[node] == node) return node;
        return par[node] = find(par[node]);
    }
     
    int find(int x, int y){
        return find(x * M + y);
    }
     
    int find(pii p){
        return find(p.st * M + p.nd);
    }
     
     
    void uni(int a, int b){
        a = find(a), b = find(b);
        if (a == b) return;
        if (sz[a] < sz[b]) swap(a, b);
        par[b] = a;
        sz[a] += sz[b];
        roots.erase(b);
    }
     
    void uni(pii a, pii b){
        uni(a.st * M + a.nd, b.st * M + b.nd);
    }
     
    void uni(int x1, int y1, int x2, int y2){
        uni(x1 * M + y1, x2 * M + y2);
    }
     
     
    int thresh = 15, thresh2 = 0, SZ = 10;
     
    int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
        int green = 0;
        h = H, w = W;
        vector<pii> dir = {{0, 1}, {1, 0}};
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                par[i * M + j] = i * M + j;
                sz[i * M + j] = 1;
                roots.insert(i * M + j);
            }
        }
     
        auto valid = [&](int a, int b){
            return (bool)(a >= 0 && a < H && b >= 0 && b < W);
        };
     
        auto dist = [&](int x1, int y1, int x2, int y2){
            int ans = abs(R[x1][y1] - R[x2][y2]);
            ans = max(ans, abs(G[x1][y1] - G[x2][y2]));
            ans = max(ans, abs(B[x1][y1] - B[x2][y2]));
            return ans;
        };
     
     
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                for (auto k : dir){
                    int a = i + k.st, b = j + k.nd;
                    if (valid(a, b) && dist(i, j, a, b) <= thresh){
                        uni(i, j, a, b);
                    }
                }
                if (G[i][j] > B[i][j] + thresh2 && G[i][j] > R[i][j] + thresh2 - 8) green++; 
            }
        }
     
     
        int cnt = 0;
     
        for (auto i : roots)
            if (sz[i] > SZ) cnt++;
    /*
        cout<<cnt<<endl;
        cout<<green<<sp<<H * W<<endl;*/
        if (green * 2 >= H * W) return 2; // nature green bla bla
        if (cnt <= 20) return 4;
        if (cnt <= 300) return 1;
        return 3;
    }
     

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

artclass.cpp:26:16: warning: 'B' defined but not used [-Wunused-variable]
   26 |     static int B[500][500];
      |                ^
artclass.cpp:25:16: warning: 'G' defined but not used [-Wunused-variable]
   25 |     static int G[500][500];
      |                ^
artclass.cpp:24:16: warning: 'R' defined but not used [-Wunused-variable]
   24 |     static int R[500][500];
      |                ^
artclass.cpp:23:16: warning: 'DIM' defined but not used [-Wunused-variable]
   23 |     static int DIM[2];
      |                ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...