답안 #385557

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385557 2021-04-04T15:08:01 Z Sprdalo Vision Program (IOI19_vision) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;
/*
int last;
vi A;

int add_not(int pos){

    int n = A.size();
    if (pos < 0 || pos >= n){
        throw SIGSEGV;
    }

    if (A[pos])
        last = 0;
    else
        last = 1;

    A.push_back(last);
    return last;
}

int add_and(vi t){
    int n = A.size();

    if (t.empty()) throw SIGSEGV;

    last = 1;
    for (int pos : t){
        if (pos < 0 || pos >= n){
            throw SIGSEGV;
        }
        last &= A[pos];
    }

    A.push_back(last);
    return last;
}
int add_or(vi t){
    int n = A.size();

    if (t.empty()) {throw SIGSEGV;}

    last = 0;
    for (int pos : t){
        if (pos < 0 || pos >= n)
            throw SIGSEGV;
        last |= A[pos];
    }

    A.push_back(last);
    return last;
}
int add_xor(vi t){
    int n = A.size();

    if (t.empty()){ throw SIGSEGV;}

    last = 0;
    for (int pos : t){
        if (pos < 0 || pos >= n){
            throw SIGSEGV;
        }
        last ^= A[pos];
    }

    A.push_back(last);
    return last;
}
*/
void moze(int h, int w){
    vi t;
    for (int i = 0; i < h*w; ++i){
        t.push_back(i);
    }

    add_or(t);
}

void ne_moze(int h, int w){
    vi t;
    for (int i = 0; i < h*w; ++i){
        t.push_back(i);
    }

    add_xor(t);
}

vi ldor,ldx,rdor,rdx;

bool check(int k, int h, int w){
    bool ok = 0;
    for (int i = 0; i < h+w-1; ++i){
        vi tor, tx;
        if (i + k > h+w-1) break;
        for (int j = i; j < i+k; ++j){
            tor.push_back(ldor[j]);
            tx.push_back(ldx[j]);
        }

        if (add_or(tor) == 1 && add_xor(tx) == 0){
            ok = 1;
            break;
        }
    } 

    if (!ok) return 0;

    ok = 0;
    for (int i = 0; i < h+w-1; ++i){
        vi tor, tx;
        if (i + k > h+w-1) break;
        for (int j = i; j < i+k; ++j){
            tor.push_back(rdor[j]);
            tx.push_back(rdx[j]);
        }

        if (add_or(tor) == 1 && add_xor(tx) == 0){
            ok = 1;
            break;
        }
    }

    return ok;
}

void construct_network(int h, int w, int k){
    vector<vi> l(h+w-1), r(h+w-1);

    int n = A.size();
    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            l[i+j].push_back(i*w+j);

        }
    }

    for (int i = 0; i < h; ++i){
        for (int j = 0; j < w; ++j){
            r[i-j+w-1].push_back(i*w+j);
        }
    }


    ldor.clear(); ldx.clear();
    int cur = 0;

    for (int i = 0; i < h+w-1; ++i){
        add_or(l[i]);
        ldor.push_back(h*w+cur);
        ++cur;
        add_xor(l[i]);
        ldx.push_back(h*w+cur);
        ++cur;
    }

    rdor.clear(); rdx.clear();
    for (int i = 0; i < h+w-1; ++i){
        add_or(r[i]);
        rdor.push_back(h*w+cur);
        ++cur;
        add_xor(r[i]);
        rdx.push_back(h*w+cur);
        ++cur;
    }

    if (check(k+1,h,w) && !check(k,h,w)){
        moze(h,w);
    } else {
        ne_moze(h,w);
    }
}
/*
signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    
    
    int h, w, k;
    cin >> h >> w >> k;

    A = vi(h*w,0);

    int q; cin >> q;

    int x1=0, y1=0, x2=0, y2=0;
    for (int e = 0; e < q; ++e){
        A[x1*w+y1] = A[x2*w+y2] = 0;
        cin >> x1 >> y1 >> x2 >> y2;
        A[x1*w+y1] = A[x2*w+y2] = 1;

        last = -1;
        construct_network(h,w,k);

        cout << last << '\n';
    }
}*/

Compilation message

vision.cpp: In function 'void moze(int, int)':
vision.cpp:91:5: error: 'add_or' was not declared in this scope
   91 |     add_or(t);
      |     ^~~~~~
vision.cpp: In function 'void ne_moze(int, int)':
vision.cpp:100:5: error: 'add_xor' was not declared in this scope
  100 |     add_xor(t);
      |     ^~~~~~~
vision.cpp: In function 'bool check(int, int, int)':
vision.cpp:115:13: error: 'add_or' was not declared in this scope
  115 |         if (add_or(tor) == 1 && add_xor(tx) == 0){
      |             ^~~~~~
vision.cpp:115:33: error: 'add_xor' was not declared in this scope
  115 |         if (add_or(tor) == 1 && add_xor(tx) == 0){
      |                                 ^~~~~~~
vision.cpp:132:13: error: 'add_or' was not declared in this scope
  132 |         if (add_or(tor) == 1 && add_xor(tx) == 0){
      |             ^~~~~~
vision.cpp:132:33: error: 'add_xor' was not declared in this scope
  132 |         if (add_or(tor) == 1 && add_xor(tx) == 0){
      |                                 ^~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:144:13: error: 'A' was not declared in this scope
  144 |     int n = A.size();
      |             ^
vision.cpp:163:9: error: 'add_or' was not declared in this scope
  163 |         add_or(l[i]);
      |         ^~~~~~
vision.cpp:166:9: error: 'add_xor' was not declared in this scope
  166 |         add_xor(l[i]);
      |         ^~~~~~~
vision.cpp:173:9: error: 'add_or' was not declared in this scope
  173 |         add_or(r[i]);
      |         ^~~~~~
vision.cpp:176:9: error: 'add_xor' was not declared in this scope
  176 |         add_xor(r[i]);
      |         ^~~~~~~
vision.cpp:144:9: warning: unused variable 'n' [-Wunused-variable]
  144 |     int n = A.size();
      |         ^