제출 #1366966

#제출 시각아이디문제언어결과실행 시간메모리
1366966novaluxPizza Party (CCO24_day1problem2)C++17
0 / 12
92 ms19940 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define int ll
#define yes cout<<"Yes" << endl;
#define no cout<<"No" << endl;
#define pb push_back
#define F first
#define S second
#define INF 1000000000000000000

ll t=1, n, m, k, q;
ll a, b, c=0, d;
ll c1, c2, c3, c4;
ll x = -1, y, z, nx, ny;
ll s, sum, res, mid, anns;
ll mx[] = {1, -1, 0, 0};
ll my[] = {0, 0, 1, -1};
string str, str1, str2;
bool tf=0, t1, t2;
char ch;
const int N = 1e6;
int mod = 1e9+7;


void prime(ll n) {
    bool tf = 1;
    if(n%2 == 0)
    {cout << "2\n"; tf = 0;}
    for(ll i = 3; i < n; i+=2) {
        if(n % i == 0) {
            cout << i << "\n";
            tf = 0;
        }
    }
    if(tf)
        cout << n << " is prime\n";
}

ll num(char ch) {
    return ch - '0';
}

ll mpower(ll x, ll y) {
    if(y == 0)
        return 1;
    ll p = mpower(x, y/2);
    if(y & 1)
        return (((p * p)%mod) * x)%mod;
    return (p * p)%mod;
}

ll power(ll x, ll y) {
    if(y == 0)
        return 1;
    ll p = power(x, y/2);
    if(y & 1)
        return p * p * x;
    return p * p;
}

void commented_Code() {/*const int MAXN = 100009;
const long long MOD = 1000000007;

long long fact[MAXN + 1], invFact[MAXN + 1];

void init() {
    fact[0] = 1;
    for (int i = 1; i <= MAXN; i++)
        fact[i] = fact[i - 1] * i % MOD;
}

long long nCr(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * mpower(fact[k], mod-2) % MOD * mpower(fact[n-k], mod-2) % MOD;
}
*/}

vector<ll> st, ord;

void solve() {
    cin >> n;
    st.assign(n, 0), ord.assign(n, 0);
    for(auto &i : st)cin >> i; for(auto &i : ord)cin >> i;
    bool tf = 1;
    a = b=  0;
    for(auto i : st)if(i == 1)a++; for(auto i : ord)if(i == 1)b++;
    if(a != b) {
        cout << -1 << endl;
        return;
    }
    for(ll i = 0; i < n; i++) {
        if(ord[i] != st[n-i-1])
            tf = 0;
    }

    if(tf) {
        cout << 1 << endl;
        for(ll i = 0; i < n ;i++)cout << "1 ";
        cout << endl;
        for(ll i = 0; i < n ;i++)cout << "1 ";
        cout << endl;
        return;
    }
    cout << 2 << endl;
    for(ll i = 0; i < n; i++) {
        if(st[i] == st[n-1])
            cout << "1 ";
        else
            cout << "2 ";
    }
    cout << endl;
    for(ll i = 0; i < n; i++) {
        if(ord[i] == st[n-1])
            cout << "1 ";
        else
            cout << "2 ";
    }
    cout << endl;

}
int32_t main() {
    ios_base:: sync_with_stdio(false),cin.tie(NULL);
    //freopen("revegetate.in" , "r" , stdin) ;
    //freopen("revegetate.out" , "w" , stdout) ;
    //init();
    //cin >> t;
    while(t--) {
        solve();
    }
    /*
     *      https://codeforces.com/blog/entry/146051
     *      https://codeforces.com/blog/entry/22616
     */
    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…