제출 #401655

#제출 시각아이디문제언어결과실행 시간메모리
401655snasibov05Vision Program (IOI19_vision)C++14
33 / 100
7 ms1480 KiB
#include "vision.h"
#include <set>

using namespace std;

#define pb push_back

void construct_network(int H, int W, int K) {

    vector<int> v;
    int k = H*W;

    set<pair<int, int>> st;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int cur = i * W + j;
            vector<int> arr;
            arr.pb(cur);
            for (int l = 0; l <= K; ++l) {
                int to = (i + l) * W + j + (K - l);
                if (to >= 0 && to < H*W && j + (K - l) < W && i + l < H && !st.count({cur, to}) && !st.count({to, cur})){
                    arr.pb(to);
                    add_and(arr);
                    arr.pop_back();
                    v.pb(k++);
                    st.insert({cur, to});
                }
                to = (i + l) * W + j - (K - l);
                if (to >= 0 && to < H*W && j - (K - l) >= 0 && i + l < H && !st.count({cur, to}) && !st.count({to, cur})){
                    arr.pb(to);
                    add_and(arr);
                    arr.pop_back();
                    v.pb(k++);
                    st.insert({cur, to});
                }
                to = (i - l) * W + j + (K - l);
                if (to >= 0 && to < H*W && j + (K - l) < W && i - l >= 0 && !st.count({cur, to}) && !st.count({to, cur})){
                    arr.pb(to);
                    add_and(arr);
                    arr.pop_back();
                    v.pb(k++);
                    st.insert({cur, to});
                }
                to = (i - l) * W + j - (K - l);
                if (to >= 0 && to < H*W && j - (K - l) >= W && i - l >= H && !st.count({cur, to}) && !st.count({to, cur})){
                    arr.pb(to);
                    add_and(arr);
                    arr.pop_back();
                    v.pb(k++);
                    st.insert({cur, to});
                }
            }
        }
    }

    add_or(v);

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...