Advertisement
a53

seti

a53
Mar 5th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. int a[10001], n;
  4. int lit[30];
  5. char s[15];
  6. ifstream fin("seti.in");
  7. ofstream fout("seti.out");
  8.  
  9. int main()
  10. {
  11. int x,i,j;
  12. char v[6];
  13. fin>>s;
  14. for(i=0;s[i]!= 0;++i)
  15. lit[s[i]-'a']=i;
  16. while(fin>>v)
  17. {
  18. x=0;
  19. for (i=0;i<4;++i)
  20. x=x*10+lit[v[i]-'a'];
  21. ++a[x];
  22. }
  23. v[4]=0;
  24. for(i=0;i<10000;++i)
  25. if(a[i]>0)
  26. {
  27. x=i;
  28. for(j=3;j>=0;--j)
  29. v[j]=s[x%10],x/=10;
  30. while(a[i]--)
  31. fout<<v<<'\n';
  32. }
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement