fork(1) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cstdlib>
  4. #include <cstdio>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int n, m, k, c[26], t;
  10. string s[1001], a[1001];
  11.  
  12. int cini (char c){
  13. return c-48-49;
  14. }
  15.  
  16.  
  17. int main(){
  18. cin.tie();
  19. ios_base::sync_with_stdio(0);
  20. freopen("radixsort.in", "r", stdin);
  21. freopen("radixsort.out", "w", stdout);
  22. cin >> n >> m >> k;
  23. for (int i = 0; i < n; i++){
  24. cin >> s[i];
  25. }
  26. for(int i = m - 1; i >= m - k; i--){
  27. for (int j = 0; j < 26; j++){
  28. c[j] = 0;
  29. }
  30. for(int j = 0; j < n; j++){
  31. c[cini(s[j][i])]++;
  32. }
  33. int cnt = 0;
  34. for (int j = 0; j < 26; j++){
  35. t = c[j];
  36. c[j] = cnt;
  37. cnt += t;
  38. }
  39. for (int j = 0; j < n; j++){
  40. a[c[cini(s[j][i])]] = s[j];
  41. c[cini(s[j][i])]++;
  42. }
  43. for(int j = 0; j < n; j++){
  44. s[j] = a[j];
  45. //cout << s[j] << " ";
  46. }
  47. }
  48. for (int i = 0; i < n; i++){
  49. cout << s[i] << endl;
  50. }
  51. return 0;
  52. }
Runtime error #stdin #stdout #stderr 0s 15304KB
stdin
3 1 1
a
c
b
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::ios_base::failure[abi:cxx11]'
  what():  basic_filebuf::underflow error reading the file: iostream error