Submission #487815

#TimeUsernameProblemLanguageResultExecution timeMemory
487815cfalasThe Xana coup (BOI21_xanadu)C++14
0 / 100
64 ms1928 KiB
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define INF 10000000 #define MOD 1000000007 #define MID ((l+r)/2) #define HASHMOD 2305843009213693951 #define ll long long #define ull unsigned long long #define F first #define S second typedef pair<ll, ll> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef map<int, int> mii; #define EPS 1e-6 #define FOR(i,n) for(int i=0;i<((int)(n));i++) #define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++) #define FOA(v, a) for(auto v : a) int t, n; vi a, b; int main(){ cin>>n; FOR(i,n-1){ int a, b; cin>>a>>b; } a.resize(n+1); FOR(i,n){ cin>>a[i+1]; } a[0] = a[1]; int ans=0; FORi(i,1,n-1){ // assume that everything before a[i-1]==0 if(a[i-1]==1){ a[i-1] = 1-a[i-1]; a[i] = 1-a[i]; a[i+1] = 1-a[i+1]; ans++; } } if(a[n-1]+a[n-2]+a[n]!= 0) cout<<"impossible\n"; else cout<<ans<<endl; }
#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...