結果

問題 No.1078 I love Matrix Construction
ユーザー ____________
提出日時 2020-06-12 22:51:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,124 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 205,144 KB
実行使用メモリ 5,008 KB
最終ジャッジ日時 2023-09-06 11:02:02
合計ジャッジ時間 5,397 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 3 ms
5,000 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,656 KB
testcase_13 AC 2 ms
5,008 KB
testcase_14 AC 2 ms
4,400 KB
testcase_15 AC 3 ms
4,568 KB
testcase_16 WA -
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> S(N+1,0);
    vector<ll> T(N+1,0);
    vector<ll> U(N+1,0);
    for(ll i=1;i<N+1;++i)cin>>S[i];
    for(ll i=1;i<N+1;++i)cin>>T[i];
    for(ll i=1;i<N+1;++i)cin>>U[i];
    vector<vector<ll>> ans(N+1, vector<ll>(N+1, -1));
    //U[i]について考察
    for(ll i=1;i<N+1;++i){
        if(U[i]==0){
            for(ll j=1;j<N+1;++j){
                if(ans[S[i]][j]==-1){
                    ans[S[i]][j]=0;
                }
                else if(ans[S[i]][j]!=0){
                    prt(-1)fl return 0;
                }
                if(ans[j][T[i]]==-1){
                    ans[j][T[i]]=0;
                }
                else if(ans[j][T[i]]!=0){
                    prt(-1)fl return 0;
                }
            }
        }
        else if(U[i]==1){
            for(ll j=1;j<N+1;++j){
                if(ans[S[i]][j]==-1){
                    ans[S[i]][j]=1;
                }
                else if(ans[S[i]][j]!=1){
                    prt(-1)fl return 0;
                }
                if(ans[j][T[i]]==-1){
                    ans[j][T[i]]=0;
                }
                else if(ans[j][T[i]]!=0){
                    prt(-1)fl return 0;
                }
            }
        }
        else if(U[i]==2){
            for(ll j=1;j<N+1;++j){
                if(ans[S[i]][j]==-1){
                    ans[S[i]][j]=0;
                }
                else if(ans[S[i]][j]!=0){
                    prt(-1)fl return 0;
                }
                if(ans[j][T[i]]==-1){
                    ans[j][T[i]]=1;
                }
                else if(ans[j][T[i]]!=1){
                    prt(-1)fl return 0;
                }
            }
        }
        else {
            for(ll j=1;j<N+1;++j){
                if(ans[S[i]][j]==-1){
                    ans[S[i]][j]=1;
                }
                else if(ans[S[i]][j]!=1){
                    prt(-1)fl return 0;
                }
                if(ans[j][T[i]]==-1){
                    ans[j][T[i]]=1;
                }
                else if(ans[j][T[i]]!=1){
                    prt(-1)fl return 0;
                }
            }
        }
    }
    for(ll i=0;i<N;++i){
        for(ll j=0;j<N;++j){
            if(ans[i+1][j+1]==1)cout<<0<<" ";
            else cout<<1<<" ";
        }
        cout<<endl;
    }fl


    return 0;
}
0