fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void testCase() {
  5. int n;cin>>n;
  6. bool dd[10]={false};
  7. for(int i=0;i<n;i++){
  8. long long x;cin>>x;
  9. while(x){
  10. dd[x%10]=true;
  11. x/=10;
  12. }
  13. }
  14. for(int i=0;i<10;i++){
  15. if(dd[i]) cout<<i<<" ";
  16. }
  17. }
  18.  
  19. int main() {
  20. ios_base::sync_with_stdio(false);
  21. cin.tie(NULL); cout.tie(NULL);
  22.  
  23. int T = 1; cin >> T;
  24. while (T--) {
  25. testCase();
  26. cout << "\n";
  27. }
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
1