Submission #1210361

#TimeUsernameProblemLanguageResultExecution timeMemory
1210361SpyrosAlivVision Program (IOI19_vision)C++20
Compilation error
0 ms0 KiB
#include "vision.h"
#include <bits/stdc++.h>
using namespace std;
/*
int add_not(int N);
int add_and(vector<int> Ns);
int add_or(vector<int> Ns);
int add_xor(vector<int> Ns);
*/
vector<int> get_dis(int r, int c, vector<vector<int>> &grid, int k) {
    int n = grid.size();
    int m = grid[0].size();
    vector<int> fin;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (abs(i - r) + abs(j - c) == k) fin.push_back(grid[i][j]);
        }
    }
    return fin;
} 

vector<int> get_row(int row, vector<vector<int>> &grid) {
    int n = grid.size();
    int m = grid[0].size();
    if (row < 0 || row >= n) return {};
    vector<int> currRow;
    for (int j = 0; j < m; j++) {
        currRow.push_back(grid[row][j]);
    }
    return currRow;
}

vector<int> get_col(int col, vector<vector<int>> &grid) {
    int n = grid.size();
    int m = grid[0].size();
    if (col < 0 || col >= m) return {};
    vector<int> currCol;
    for (int j = 0; j < n; j++) {
        currCol.push_back(grid[j][col]);
    }
    return currCol;
}

void construct_network(int H, int W, int K) {
    int n = H;
    int m = W;
    int k = K;
    vector<vector<int>> grid(n, vector<int>(m));
    int curr = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            grid[i][j] = curr++;
        }
    }
    int sameCol, sameRow, adjCol, adjRow;
    // take the XOR of the ORs of all columns: true -> they are in the same column
    // same for rows
    vector<int> ors;
    for (int col = 0; col < m; col++) {
        vector<int> currCol = get_col(col, grid);
        ors.push_back(add_or(currCol));
    }
    sameCol = get_xor(ors);
    ors.clear();
    for (int row = 0; row < n; row++) {
        vector<int> currRow = get_row(row, grid);
        ors.push_back(add_or(currRow));
    }
    sameRow = get_xor(ors);
    // take the XOR of the ORs of all ADJACENT columns: true -> the are in adjacnt columns
    ors.clear();
    for (int col = 0; col <= m; col++) {
        vector<int> a = get_col(col, grid);
        vector<int> b = get_col(col-1, grid);
        for (auto x: b) a.push_back(x);
        ors.push_back(add_or(a));
    }
    adjCol = get_xor(ors);
    ors.clear();
    for (int row = 0; row <= n; row++) {
        vector<int> a = get_row(row, grid);
        vector<int> b = get_row(row-1, grid);
        for (auto x: b) a.push_back(x);
        ors.push_back(add_or(a));
    }
    adjRow = get_xor(ors);
    add_or({add_and({adjCol, sameRow}), add_and({sameCol, adjRow})});
}

Compilation message (stderr)

vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:63:15: error: 'get_xor' was not declared in this scope; did you mean 'get_row'?
   63 |     sameCol = get_xor(ors);
      |               ^~~~~~~
      |               get_row