답안 #261284

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
261284 2020-08-11T15:51:05 Z caoash Vision Program (IOI19_vision) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h> 
#include "vision.h"

using namespace std;

using ll = long long;

using vi = vector<int>;
#define pb push_back
#define rsz resize
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

int add_not(int N) {

}

int add_and(vi N) {

}

int add_or(vi N) {

}

int add_xor(vi N) {

}

void construct_network(int H, int W, int K) {
    vi ups;
    for (int y = 0; y < W; y++) {
        pi st = mp(0, y);
        vi diag;
        while (st.f < H && st.s < W) {
            diag.pb(H * st.f + st.s);
            ++st.f, ++st.s;
        }
        ups.pb(add_or(diag)); 
    }
    for (int x = 1; x < H; x++) {
        pi st = mp(x, 0);
        vi diag;
        while (st.f < H && st.s < W) {
            diag.pb(H * st.f + st.s);
            ++st.f, ++st.s;
        }
        ups.pb(add_or(diag));
    }
    vi downs;
    for (int y = 0; y < W; y++) {
        pi st = mp(0, y);
        vi diag;
        while (st.f >= 0 && st.s >= 0) {
            diag.pb(H * st.f + st.s);
            --st.f, --st.s;
        }
        downs.pb(add_or(diag));
    }
    for (int x = 1; x < H; x++) {
        pi st = mp(x, W - 1);
        vi diag;
        while (st.f >= 0 && st.s >= 0) {
            diag.pb(H * st.f + st.s);
            --st.f, --st.s;
        }
        downs.pb(add_or(diag));
    }
    vi psup(sz(ups));
    for (int i = 0; i < sz(ups); i++) {
        if (i == 0) {
            psup[i] = ups[i]; 
        }
        else {
            psup[i] = add_xor({ups[i], psup[i - 1]});
        }
    }
    vi pdown(sz(downs));
    for (int i = 0; i < sz(downs); i++) {
        if (i == 0) {
            pdown[i] = downs[i];
        }
        else {
            pdown[i] = add_xor({downs[i], pdown[i - 1]});
        }
    }
    int upok = 0, downok = 0;
    for (int i = 0; i < sz(ups) - K + 1; i++) {
        vi curr;
        for (int j = i; j < i + K; j++) {
            curr.pb(psup[j]);
        } 
        if (i == 0) upok = add_and(curr);
        else upok = add_or({upok, add_and(curr)});
    }
    for (int i = 0; i < sz(downs) - K + 1; i++) {
        vi curr;
        for (int j = i; j < i + K; j++) {
            curr.pb(pdown[j]);
        } 
        if (i == 0) downok = add_and(curr);
        else downok = add_or({downok, add_and(curr)});
    }
    int NK = K + 1;
    int upok2 = 0, downok2 = 0;
    for (int i = 0; i < sz(ups) - NK + 1; i++) {
        vi curr;
        for (int j = i; j < i + NK; j++) {
            curr.pb(psup[j]);
        } 
        if (i == 0) upok2 = add_and(curr);
        else upok2 = add_or({upok2, add_and(curr)});
    }
    for (int i = 0; i < sz(downs) - NK + 1; i++) {
        vi curr;
        for (int j = i; j < i + NK; j++) {
            curr.pb(pdown[j]);
        } 
        if (i == 0) downok2 = add_and(curr);
        else downok2 = add_or({downok2, add_and(curr)});
    }
    return add_and({add_or({upok, downok}), add_not(add_or({upok2, downok2}))});
}

Compilation message

vision.cpp: In function 'int add_not(int)':
vision.cpp:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'int add_and(vi)':
vision.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'int add_or(vi)':
vision.cpp:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'int add_xor(vi)':
vision.cpp:33:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:127:79: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return add_and({add_or({upok, downok}), add_not(add_or({upok2, downok2}))});
                                                                               ^