Submission #579489

# Submission time Handle Problem Language Result Execution time Memory
579489 2022-06-19T09:04:15 Z keta_tsimakuridze Vision Program (IOI19_vision) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "vision.h"
using namespace std;
const int N = 2e5 + 5;
int id_or[N], id_xor[N], cur;
vector<int> X;
void add_and(vector<int> Ns) {

    int x = 1;
    for(int i = 0; i < Ns.size(); i++) {
        x &= X[Ns[i]];
    }
    X.push_back(x);
}

void add_or(vector<int> Ns) {

    int x = 0;
    for(int i = 0; i < Ns.size(); i++) {
        x |= X[Ns[i]];
    }

    X.push_back(x);
}

void add_xor(vector<int> Ns) {

    int x = 0;
    for(int i = 0; i < Ns.size(); i++) {
        x ^= X[Ns[i]];
    }
    X.push_back(x);
}

void add_not(int N) {
	X.push_back(1^X[N]);
}

vector<int> d[N];
int go(int n, int k) {
	vector<int> V;
	for(int i = 0; i < n; i++) {
		id_or[i] = ++cur; add_or(d[i]);
		id_xor[i] = ++cur; add_xor(d[i]);
		add_not(cur); ++cur;
		add_and({cur, id_or[i]});
		V.push_back(++cur);
	}
	for(int i = k; i < n; i++) {
		vector<int> v;
		for(int j = i - k ; j <= i; j++) {
			v.push_back(id_or[j]);
		}
		++cur;
		add_or(v);
		++cur;
		add_xor(v);

		add_not(cur); ++cur;

		add_and({cur, cur - 2}); ++cur;
		V.push_back(cur);
	}

	add_or(V); ++cur;
	return cur;
}
void calc(int n, int m,int k) {
    for(int i = 0; i < n + m; i++) d[i].clear();
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			d[i - j + m - 1].push_back(i * m + j);
		}
	}
	int id1 = go(n + m - 1, k);
	for(int i = 0; i < n + m; i++) {
		d[i].clear();
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			d[i + j].push_back(i * m + j);
		}
	}
	int id2 = go(n + m - 1, k);
	add_and({id1, id2}); ++cur;

}
void construct_network(int H, int W, int K) {
	cur = H * W; --cur;
	calc(H, W, K);
	int pcur = cur;
	calc(H, W, K - 1);
	add_xor({pcur, cur});
}
/*
int main() {
	int H, W, K;
	assert(3 == scanf("%d%d%d", &H, &W, &K));
	for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int a;
            cin >> a;
            X.push_back(a);
        }
	}
	construct_network(H, W, K);
	cout << X.back() << endl;
}*/

Compilation message

vision.cpp:7:6: error: ambiguating new declaration of 'void add_and(std::vector<int>)'
    7 | void add_and(vector<int> Ns) {
      |      ^~~~~~~
In file included from vision.cpp:2:
vision.h:10:5: note: old declaration 'int add_and(std::vector<int>)'
   10 | int add_and(std::vector<int> Ns);
      |     ^~~~~~~
vision.cpp: In function 'void add_and(std::vector<int>)':
vision.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i = 0; i < Ns.size(); i++) {
      |                    ~~^~~~~~~~~~~
vision.cpp: At global scope:
vision.cpp:16:6: error: ambiguating new declaration of 'void add_or(std::vector<int>)'
   16 | void add_or(vector<int> Ns) {
      |      ^~~~~~
In file included from vision.cpp:2:
vision.h:12:5: note: old declaration 'int add_or(std::vector<int>)'
   12 | int add_or(std::vector<int> Ns);
      |     ^~~~~~
vision.cpp: In function 'void add_or(std::vector<int>)':
vision.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0; i < Ns.size(); i++) {
      |                    ~~^~~~~~~~~~~
vision.cpp: At global scope:
vision.cpp:26:6: error: ambiguating new declaration of 'void add_xor(std::vector<int>)'
   26 | void add_xor(vector<int> Ns) {
      |      ^~~~~~~
In file included from vision.cpp:2:
vision.h:14:5: note: old declaration 'int add_xor(std::vector<int>)'
   14 | int add_xor(std::vector<int> Ns);
      |     ^~~~~~~
vision.cpp: In function 'void add_xor(std::vector<int>)':
vision.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0; i < Ns.size(); i++) {
      |                    ~~^~~~~~~~~~~
vision.cpp: At global scope:
vision.cpp:35:6: error: ambiguating new declaration of 'void add_not(int)'
   35 | void add_not(int N) {
      |      ^~~~~~~
In file included from vision.cpp:2:
vision.h:16:5: note: old declaration 'int add_not(int)'
   16 | int add_not(int N);
      |     ^~~~~~~