Submission #537092

# Submission time Handle Problem Language Result Execution time Memory
537092 2022-03-14T12:58:34 Z DJ035 The Xana coup (BOI21_xanadu) C++17
0 / 100
16 ms 328 KB
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include <bits/stdc++.h>
#define MEM 222
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define pf push_front
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz size()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll INF = 1e17+7;
const ll MOD = 998244353;
ll gcd(ll a, ll b){
    if(a%b) return gcd(b, a%b);
    return b;
}
ll t,n,m;
ll a[MEM], b[MEM];
map<ll, ll> mp;
ll dc(ll c, ll h){
    if(c%(m*m)) return 1;
    else return 0;
}
signed main(){
    sanic; cin.tie(0);
    cin >> n;
    for(int i=1; i<n; i++){
        ll q1,q2;
        cin >> q1 >> q2;
    }
    for(int i=0; i<n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    b[0] ^= 1;
    b[1] ^= 1;
    ll o=1,o2=0;
    for(int i=1; i<n; i++){
        if(b[i-1]==1) {
            b[i-1] ^= 1;
            b[i] ^= 1;
            b[i+1] ^= 1;
            o++;
        }
    }
    for(int i=1; i<n; i++){
        if(a[i-1]==1) {
            a[i-1] ^= 1;
            a[i] ^= 1;
            a[i+1] ^= 1;
            o2++;
        }
    }
    ll aa=0, bb=0;
    for(int i=0; i<n; i++)
        aa += a[i], bb += b[i];
    if(aa*bb>0) cout << "impossible\n";
    else cout << min(o, o2);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -