Title Link: http://hihocoder.com/problemset/problem/1114
Finally began to brush the Hihocoder ~
1 /*2 * Problem:hihocoder #11143 * AUTHOR:SHJWUDP4 * Created TIME:2015/4/2 Thursday 14:29:535 * File name:233.cpp6 * state:accepted7 * Memo:function8 */9#include <iostream>Ten#include <cstdio> One#include <cstring> A#include <algorithm> - - using namespacestd; the - Const intmaxa=1e5+7; - - intN; + intArr[maxa]; - intbomb[2][maxa]; + intOpa[maxa], Opb[maxa], LA, LB; A BOOLFuncint*b) { at for(intI=1; i<n; i++) { -b[i+1]=arr[i]-(b[i]+b[i-1]); - if(! (0<=b[i+1] && b[i+1]<=1))return false; - } - returnb[n]+b[n-1]==Arr[n]; - } in voidsolve () { -bomb[0][0]=bomb[1][0]=0; tobomb[0][1]=0; + BOOLFlag1=func (bomb[0]); -bomb[1][1]=1; the BOOLFlag2=func (bomb[1]); *La=0; lb=0; $ if(Flag1 &&Flag2) {Panax Notoginseng for(intI=1; i<=n; i++) { - if(bomb[0][i] = = bomb[1][i]) { the if(bomb[0][i]) opa[la++]=i; + Elseopb[lb++]=i; A } the } +}Else if(Flag1 | |Flag2) { - int*b=flag1?bomb[0]:bomb[1]; $ for(intI=1; i<=n; i++) { $ if(B[i]) opa[la++]=i; - Elseopb[lb++]=i; - } the } - }Wuyi intMain () { the #ifndef Online_judge -Freopen ("inch","R", stdin); Wu //freopen ("Out", "w", stdout); - #endif About intT; $scanf"%d", &T); - while(t--) { -scanf"%d", &N); - for(intI=1; i<=n; i++) { Ascanf"%d", &arr[i]); + } the - solve (); $printf"%d", LA); the for(intI=0; i<la; i++) theprintf"%d", Opa[i]); theprintf"\n%d", LB); the for(intI=0; i<lb; i++) -printf"%d", Opb[i]); inprintf"\ n"); the } the return 0; About}
Hihocoder #1114
Hihocoder #1114