Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main()
- {
- char code[100001]= {'\0'};
- int i,j,n,check=1,total=0;
- scanf("%d",&n);
- for(i=0; i<n; i++)
- {
- scanf("%s",&code[i]);
- }
- for(i=0; i<n; i++)
- {
- for(j=check; j<n; j++)
- {
- if(code[check]==code[i] && code[i]!='1')
- {
- code[i]='1';
- code[check]='1';
- total+=2;
- i-=1;
- }
- else
- {
- i=check-1;
- check++;
- break;
- }
- check++;
- }
- }
- //printf("%s %d\n",code,total);
- if(strlen(code)-total==0)
- {
- printf("0\nempty");
- return 0;
- }
- printf("%d\n",strlen(code)-total);
- for(i=strlen(code)-1;i>=0;i--)
- {
- if(code[i]!='1') printf("%c",code[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement