Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- const int SIZE = 200 * 1000 + 1;
- int N,c[SIZE];
- int change(){
- for(int i=1;i<N-1;i++){
- if(c[i+1]<=0){
- for(int j=i;j<=N;j++){
- if((i-j)%2==0)c[j]--;
- else c[j]++;
- }
- return i;
- }
- }
- if(c[N]<0){
- c[N-1]--;
- c[N]++;
- return N-1;
- }
- if(c[N]>0){
- c[N]--;
- return N;
- }
- return -1;
- }
- int main(){
- scanf("%d",&N);
- for(int i=1;i<=N;i++){
- scanf("%d",&c[i]);
- c[i]=c[i]*2-c[i-1];
- }
- int s=change();
- int t=change();
- int z=change();
- if(z!=-1)return 0*puts("Impossible");
- if(s==-1){s=N-1,t=N;c[N-1]--;}
- printf("%d\n",s);
- while(s!=1){
- s--;
- c[s]--;
- printf("<");
- }
- while(s<t){
- printf(">");
- c[s]--;
- while(c[s]>0){
- printf("<>");
- c[s]-=2;
- }
- s++;
- }
- while(s<N){
- c[s]--;
- printf(">");
- s++;
- }
- while(s>t){
- s--;
- if(!c[s])break;
- printf("<");
- c[s]--;
- while(c[s]>0){
- printf("><");
- c[s]-=2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment