Submission #992268

# Submission time Handle Problem Language Result Execution time Memory
992268 2024-06-04T08:02:04 Z MarwenElarbi Vision Program (IOI19_vision) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//#include "vision.h"

using namespace std;
#define fi first
#define se second
#define ll long long
#define pb push_back

int add_and(std::vector<int> Ns){
    bool ans=1;
    for (int i = 0; i < Ns.size(); ++i)
    {
        ans&=Ns[i];
    }
    return ans;
}

int add_or(std::vector<int> Ns){
    bool ans=0;
    for (int i = 0; i < Ns.size(); ++i)
    {
        ans|=Ns[i];
    }
    return ans;
}

int add_xor(std::vector<int> Ns){
    bool ans=0;
    for (int i = 0; i < Ns.size(); ++i)
    {
        ans^=Ns[i];
    }
    return ans;
}

int add_not(int N){
    return !N;
}

void construct_network(int H, int W, int K) {
    bool grid[H+1][W];
    pair<int,int> fst={-1,-1};
    pair<int,int> lst={-1,-1};
    pair<int,int> wa={-1,-1};
    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            grid[i][j]=add_and({i*H+j});
            //cout <<grid[i][j]<<" ";
            if(grid[i][j]==1&&fst==make_pair(-1,-1)){
                fst={i,j};
            }else if(grid[i][j]==1){
                lst={i,j};
            }
        }//cout <<endl;
    }
    //cout <<fst.fi<<" "<<fst.se<<" "<<lst.fi<<" "<<lst.se<<endl;
    if(abs(fst.fi-lst.fi)+abs(lst.se-fst.se)==K) add_and({fst.fi*H+fst.se});
    else add_not(fst.fi*H+fst.se);
    return;
}

Compilation message

vision.cpp: In function 'int add_and(std::vector<int>)':
vision.cpp:12:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int i = 0; i < Ns.size(); ++i)
      |                     ~~^~~~~~~~~~~
vision.cpp: In function 'int add_or(std::vector<int>)':
vision.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0; i < Ns.size(); ++i)
      |                     ~~^~~~~~~~~~~
vision.cpp: In function 'int add_xor(std::vector<int>)':
vision.cpp:30:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i = 0; i < Ns.size(); ++i)
      |                     ~~^~~~~~~~~~~
vision.cpp: In function 'void construct_network(int, int, int)':
vision.cpp:45:19: warning: variable 'wa' set but not used [-Wunused-but-set-variable]
   45 |     pair<int,int> wa={-1,-1};
      |                   ^~
/usr/bin/ld: /tmp/ccvxrC1F.o: in function `add_and(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x150): multiple definition of `add_and(std::vector<int, std::allocator<int> >)'; /tmp/ccNSA91E.o:vision.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/ccvxrC1F.o: in function `add_or(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x170): multiple definition of `add_or(std::vector<int, std::allocator<int> >)'; /tmp/ccNSA91E.o:vision.cpp:(.text+0x50): first defined here
/usr/bin/ld: /tmp/ccvxrC1F.o: in function `add_xor(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x190): multiple definition of `add_xor(std::vector<int, std::allocator<int> >)'; /tmp/ccNSA91E.o:vision.cpp:(.text+0x90): first defined here
/usr/bin/ld: /tmp/ccvxrC1F.o: in function `add_not(int)':
grader.cpp:(.text+0x1b0): multiple definition of `add_not(int)'; /tmp/ccNSA91E.o:vision.cpp:(.text+0xd0): first defined here
collect2: error: ld returned 1 exit status