이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |