fork download
  1. #include<stdio.h>
  2.  
  3. char S[12121212];
  4. int main() {
  5. int t, tc;scanf("%d",&t);
  6. for (int tc = 0; tc < t; tc++) {
  7. int n; scanf("%d",&n);
  8. scanf("%s",S);
  9. int p = 0;
  10. for (int i = 0; S[i]; i++) {
  11. if(S[0] != S[i]) {
  12. p = i;
  13. break;
  14. }
  15. }
  16. if (p == 0) {
  17. puts("0");
  18. continue;
  19. }
  20. for(int i = p; S[i]; i++) {
  21. printf("%d", (S[i-p]-'0')^(S[i]-'0'));
  22. }
  23. puts("");
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 5324KB
stdin
4
3
010
5
10101
5
00100
5
11111
stdout
11
1111
101
0