Language: C++

#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
#include<vector>
#include<queue>

namespace ProconLib{
    
    template<typename cap_t,cap_t INF,typename edge_t>
    class FlowImpl{
        protected:
        using Edges=std::vector<edge_t>;
        using Graph=std::vector<Edges>;
        int N;
        Graph g;
        std::vector<int> level;
        std::vector<int> iter;
        void bfs(int s);
        cap_t dfs(int v,int t,cap_t f);
        FlowImpl(int N):N(N),g(N){};
    };

    template<typename cap_t,cap_t INF,typename edge_t>
    void FlowImpl<cap_t,INF,edge_t>::bfs(int s){
        level.assign(N,-1);
        std::queue<int> que;
        level[s]=0;
        que.push(s);
        while(!que.empty()){
            int v=que.front(); que.pop();
            for(int i=0;i<g[v].size();i++){
                edge_t &e=g[v][i];
                if(e.cap>0 && level[e.to]<0){
                    level[e.to]=level[v]+1;
                    que.push(e.to);
                }
            }
        }
    }
    template<typename cap_t,cap_t INF,typename edge_t>
    cap_t FlowImpl<cap_t,INF,edge_t>::dfs(int v,int t,cap_t f){
        if(v==t) return f;
        for(int& i=iter[v];i<g[v].size();i++){
            edge_t& e=g[v][i];
            if(e.cap>0 && level[v]<level[e.to]){
                cap_t d=dfs(e.to,t,std::min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    g[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }
}#include<utility>
namespace ProconLib{
    namespace impl{
        template<typename T>
        struct EdgeForMaximumFlow;
    }
    
    template<typename cap_t=long long,cap_t INF=cap_t(1e9+9)>
    class MaximumFlow:protected FlowImpl<cap_t,INF,impl::EdgeForMaximumFlow<cap_t>>{
        protected:
        using Edge=impl::EdgeForMaximumFlow<cap_t>;
        using Super=FlowImpl<cap_t,INF,Edge>;
        using Super::N;
        using Super::g;
        using Super::level;
        using Super::iter;
        using Super::bfs;
        using Super::dfs;
        public:
        using Tracer = std::pair<int,int>;
        MaximumFlow(int N):Super(N){}
        Tracer addEdge(int from,int to,cap_t cap);
        cap_t maximumFlow(int s,int t);
        cap_t getCapOf(Tracer t){return g[t.first][t.second].cap;};
    };
    
    namespace impl{
        template<typename T>
        struct EdgeForMaximumFlow{
            int to;
            T cap;
            int rev;
            EdgeForMaximumFlow(int to,T cap,int rev):to(to),cap(cap),rev(rev){}
        };
    }

    template<typename cap_t,cap_t INF>
    cap_t MaximumFlow<cap_t,INF>::maximumFlow(int s,int t){
        cap_t flow=0;
        while(true){
            bfs(s);
            if(level[t]<0) return flow;
            iter.assign(N,0);
            cap_t f;
            while((f=dfs(s,t,INF))>0){
                flow+=f;
            }
        }
    }
    template<typename cap_t,cap_t INF>
    typename MaximumFlow<cap_t,INF>::Tracer MaximumFlow<cap_t,INF>::addEdge(int from,int to,cap_t cap){
        Tracer t = Tracer{from,g[from].size()};
        g[from].push_back(Edge(to,cap,int(g[to].size())));
        g[to].push_back(Edge(from,cap_t(0),int(g[from].size())));
        return t;
    }

    
}using namespace std;
using ll=long long;
using ull = unsigned long long;
using vi=vector<int>;
using vvi=vector<vector<int>>;
int n;
vector<int> s,t;
vvi solve(vector<int> &u,vector<int>& v){
    vvi mat(n,vi(n,-1));
    vector<int> flagS(n),flagT(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(u[i]==v[j]){
                mat[i][j]=u[i];
                flagS[i] = true;
                flagT[j] = true;
            }
            else{
                if(!s[i] && u[i]){
                    mat[i][j] = 1;
                    flagS[i] = true;
                }
                if(s[i] && !u[i]){
                    mat[i][j] = 0;
                    flagS[i] = true;
                }
                if(!t[i] && v[i]){
                    mat[i][j] = 1;
                    flagT[j] = true;
                }
                if(t[i] && !v[i]){
                    mat[i][j] = 0;
                    flagT[j] = true;
                }
            }
        }
    }
    const int S = n*n+2*n;
    const int T = n*n+2*n+1;
    
    ProconLib::MaximumFlow<> flow(n*n+2*n+2);
    using Tracer = typename ProconLib::MaximumFlow<>::Tracer;
    for(int i=0;i<n;i++) flow.addEdge(n*n+i,T,1),flow.addEdge(n*n+n+i,T,1);
    struct Tup{
        Tracer t;
        int i,j;
        bool isU;
    };
    vector<Tup> tups;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(mat[i][j]==-1){
                int v = i*n+j;
                flow.addEdge(S,v,1);
                auto t=flow.addEdge(v,n*n+i,1);
                tups.push_back(Tup{t,i,j,true});
                t=flow.addEdge(v,n*n+n+j,1);
                tups.push_back(Tup{t,i,j,false});
            }
        }
    }

    for(auto tup:tups){
        if(!flow.getCapOf(tup.t)){
            if(tup.isU) mat[tup.i][tup.j] = u[tup.i];
            else mat[tup.i][tup.j] = v[tup.j];
        }
    }
    for(int i=0;i<n;i++)for(int j=0;j<n;j++) if(mat[i][j]==-1) mat[i][j]=0;
    return mat;
}

int main(){
    cin>>n;
    s.resize(n),t.resize(n);
    vector<ull> u(n),v(n);
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<n;i++) cin>>t[i];
    for(int i=0;i<n;i++) cin>>u[i];
    for(int i=0;i<n;i++) cin>>v[i];

    vector<vector<ull>> res(n,vector<ull>(n));
    for(int b=0;b<64;b++){
        vector<int> u2(n),v2(n);
        for(int i=0;i<n;i++){
            u2[i]=(u[i]>>b)&1;
            v2[i]=(v[i]>>b)&1;
        }
        auto mat = solve(u2,v2);
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                res[i][j] += ull(mat[i][j])<<b;
            }
        }
    }

    bool isok=true;
    vector<ull> u2(n);
    for(int i=0;i<n;i++){
        if(!s[i]){
            u2[i] = -1;
            for(int j=0;j<n;j++) u2[i]&=res[i][j];
        }
        else{
            for(int j=0;j<n;j++) u2[i]|=res[i][j];
        }
        isok = isok&&(u2[i]==u[i]);
    }
    vector<ull> v2(n);
    for(int j=0;j<n;j++){
        if(!t[j]){
            v2[j] = -1;
            for(int i=0;i<n;i++) v2[j]&=res[i][j];
        }
        else{
            for(int i=0;i<n;i++) v2[j]|=res[i][j];
        }
        isok = isok&&(v2[j]==v[j]);
    }
    

    if(isok){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                cout<<res[i][j]<<" ";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    
    return 0;
}


Compiler output:
a.cc:77:2: error: stray '#' in program
   77 | }#include<utility>
      |  ^
a.cc:77:3: error: 'include' does not name a type
   77 | }#include<utility>
      |   ^~~~~~~
a.cc: In function 'vvi solve(std::vector<int>&, std::vector<int>&)':
a.cc:175:16: error: 'MaximumFlow' is not a member of 'ProconLib'
  175 |     ProconLib::MaximumFlow<> flow(n*n+2*n+2);
      |                ^~~~~~~~~~~
a.cc:175:28: error: expected primary-expression before '>' token
  175 |     ProconLib::MaximumFlow<> flow(n*n+2*n+2);
      |                            ^
a.cc:175:30: error: 'flow' was not declared in this scope
  175 |     ProconLib::MaximumFlow<> flow(n*n+2*n+2);
      |                              ^~~~
a.cc:176:40: error: 'MaximumFlow' in namespace 'ProconLib' does not name a template type
  176 |     using Tracer = typename ProconLib::MaximumFlow<>::Tracer;
      |                                        ^~~~~~~~~~~
a.cc:179:9: error: 'Tracer' does not name a type
  179 |         Tracer t;
      |         ^~~~~~
a.cc:198:31: error: 'struct solve(std::vector<int>&, std::vector<int>&)::Tup' has no member named 't'
  198 |         if(!flow.getCapOf(tup.t)){
      |                               ^