#pragma GCC optimize("Ofast") #pragma GCC target ("avx") #include using namespace::std; //struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout< // #include // #include // #include // #include // #include // #include // #include // #include // using boost::math::tools::brent_find_minima; // #include // #include // namespace mp = boost::multiprecision; // typedef mp::number> cdouble; // typedef mp::cpp_int cint; // #include #include #include #include #include templateusing pbds=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; templateusing pbds_map=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; templateusing pqueue =__gnu_pbds::priority_queue,__gnu_pbds::rc_binomial_heap_tag>; typedef long long lint; typedef long long ll; typedef long double ldouble; typedef vector vec; typedef vector> mat; typedef vector>> mat3; typedef vector dvec; typedef vector> dmat; typedef vector>> dmat3; typedef vector svec; typedef vector> smat; typedef vector>> smat3; templateusing Vec=vector; templateusing Mat=vector>; templateusing Mat3=vector>>; templateusing Mat4=vector>>>; templateusing pvec=vector>; templateusing pmat=vector>>; templateusing pmat3=vector>>>; templateusing pmat4=vector>>>>; templateusing tvec=vector>; templateusing tmat=vector>>; templateusing tmat3=vector>>>; templateusing tmat4=vector>>>>; #define rep(i, n) for(lint i = 0; i < (lint)(n); i++) #define irep(i) for(lint i = 0;; i++) #define irep1(i) for(lint i = 1;; i++) #define irep2(i) for(lint i = 2;; i++) #define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--) #define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--) #define repi(i,a,b) for(lint i=lint(a);ilint(b);i+=c) #define all(x) (x).begin(),(x).end() #define PI 3.141592653589793 #define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5)) //#define input(a,n) lint n;cin>>n;vectora(n);rep(i,n)cin>>a[i]; #define SUM(v) accumulate(all(v),0LL) #define INF (1LL<<60) #define IINF (1<<30) #define EPS (1e-10) #define LINF 9223372036854775807 //#define MOD 998244353LL #define MOD 1000000007LL #define endl "\n" templateinline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<inline void numout2(T t){for(auto i:t)numout(i);} templateinline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<inline void output2(T t){for(auto i:t)output(i);} templateinline void _output(T t){bool f=0;for(int i=0;iinline void _output2(T t){for(int i=0;iT in(){return *istream_iterator(cin);} templateinline T gcd(T a,T b){return b?gcd(b,a%b):a;} templateinline T lcm(T a,T b){return a/gcd(a,b)*b;} templateinline T minq(T a,T b){return min(a,b);} templateinline T maxq(T a,T b){return max(a,b);} inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;} inline bool chmax(auto& s,const auto& t){bool res=s dx={-1,1,0,0,1,1,-1,-1}; const vector dy={0,0,-1,1,1,-1,1,-1}; // template // class FFT{ // using u64 = std::uint_fast64_t; // using C=complex; // int n=1; // public: // vector pow(const vector& a,lint x){ // const int size=a.size()*2-1; // int h=0; // while(n ires(n,0); // ires[0]=1; // while(x){ // if(x&1){ // for(int i=0;i mul(const vector& a,const vector& b){ // const int size=a.size()+b.size()-1; // int h=0; // while(n ires(n); // for(int i=0;i itoc(const vector& s,const vector& t,const int& n){ // vector res(n); // for(int i=0;i itoc(const vector& t,const int& n){ // vector res(n); // for(int i=0;i ctoi(const vector& v,const int& size){ // vector res(size); // for(int i=0;i(size,v.size());i++)res[i]=recast(v[i].real()); // return res; // } // vector fft(vector& v,const int& h,const bool& inv){ // int n=v.size(),mask=n-1; // assert((n&(n-1))==0);; // vector tmp(n); // C table[n]; // double theta =2*M_PI*(inv?-1:1)/n; // C zeta(cos(theta),sin(theta)); // table[0]=1; // for(int i=1;i>1,t=h-1;j>=1;j>>=1,--t) { // for(int k=0;k>t; // i は 上 h - t 桁 // tmp[k]=v[((i<<(t+1))|s)&mask]+table[i*j]*v[((i<<(t+1))|j|s)&mask]; // // ζ_(2^(h - t))^i // } // swap(v,tmp); // } // if(inv)for(int i=0;iclass SEG{ lint n=1; vector node; T e; F f; public: SEG(const vector& v,const T& e):e(e){ while(n0){ x=(x-1)/2; node[x]=f(node[x*2+1],node[x*2+2]); } } inline T get(const int& a,const int& b){return get(a,b,0,0,n);} private: T get(const int& a,const int& b,const int& k,const int& l,const int& r){ if(r<=a||b<=l)return e; if(a<=l&&r<=b)return node[k]; else{ T vl=get(a,b,k*2+1,l,(l+r)/2); T vr=get(a,b,k*2+2,(l+r)/2,r); return f(vl,vr); } } }; templateinline auto make_segment(const int& size,const T& e,const F& f){return SEG(size,e,f);} int main(){ lint n; cin>>n; mat v(n,vec(n,0)); vec a(n); rep(i,n)rep(j,n)cin>>v[i][j]; rep(i,n)cin>>a[i]; vec sinrai(n); rep(i,n)rep(j,n){ sinrai[i]+=v[i][j]<