Submission #537093

#TimeUsernameProblemLanguageResultExecution timeMemory
537093DJ035The Xana coup (BOI21_xanadu)C++17
0 / 100
23 ms2004 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...