Test instructions and Analysis
A slightly more complicated mind problem. Anyway this is all thinking problem, on a violent water problem (B).
Code
#include <bits/stdc++.h> #define MP make_pair#define PB emplace_back#define fi first#define se second#define ZERO (x ) memset ((x), 0, sizeof (x)) #define ALL (x) (x). Begin (), (x). End () #define REP (I, A, b) for (Reptype i = (a); I <= (b); ++i ) #define PER (I, a, b) for (Reptype i = (a); I >= (b); i) #define Quickio Ios::sync_with_stdio (FAL SE); Cin.tie (0); Cout.tie (0); using namespace std;using ll=long long;using reptype=int;int main () {int n; cin>>n; Vector<int> VEC; Rep (i,1,n) {int tmp; cin>>tmp; VEC. PB (TMP); } if (n==1) {if (vec[0]==0) {cout<< "YES" <<endl; Cout<<0<<endl;} else cout<< "NO" <<endl; } else {if (vec[n-1]==1) cout<< "NO" <<endl; else if (vec[n-1]==0 && vec[n-2]==1) {cout<< "YES" <<endl; Rep (i,0,n-1) {if (i!=0) cout<< ""; cout<<vec[i]; } cout<<endl; } else//0 0 {Rep (i,0,n-3) {if (vec[i]==0) { cout<< "YES" <<endl; Rep (j,0,i-1) {if (j!=0) cout<< ","; cout<<vec[j]; } if (i-1>=0) cout<< ","; cout<< "(0-> ("; Rep (j,i+1,n-3) {cout<<vec[j]<< ","; } cout<< "0))->0" <<endl; return 0; }} cout<< "NO" <<endl; }} return 0;}
Daily training "brackets in implications (codeforces Round 306 Div.2 E)