답안 #537091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537091 2022-03-14T12:55:26 Z DJ035 The Xana coup (BOI21_xanadu) C++17
0 / 100
23 ms 3124 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 444444
#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 ans=0;
    for(int i=0; i<n; i++)
        ans += min(a[i], b[i]);
    if(ans>0) cout << "impossible\n";
    else cout << min(o, o2);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 3108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 3124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -