记录编号 569058 评测结果 AAAAAAAAAA
题目名称 [NOIP 2004]火星人 最终得分 100
用户昵称 Gravatarlihaoze 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2022-02-15 17:54:19 内存使用 0.00 MiB
显示代码纯文本
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstring>
  4. #include <string>
  5. #include <algorithm>
  6. #define OPEN(_x) freopen(#_x".in", "r", stdin); freopen(#_x".out", "w", stdout)
  7. #define ABS(_x) ((_x)<0?(-(_x)):(_x))
  8. #define MAX(_a, _b) ((_a)<(_b)?(_b):(_a))
  9. #define MIN(_a, _b) ((_a)>(_b)?(_b):(_a))
  10. #define fi first
  11. #define se second
  12.  
  13. using namespace std;
  14.  
  15. typedef long long ll;
  16. typedef pair<int, int> PII;
  17.  
  18. namespace IO{
  19. template<typename T>
  20. inline T read() {
  21. T ret=0, sig=1; char ch=0;
  22. while(ch<'0'||ch>'9') { if(ch=='-') sig=-1; ch=getchar(); }
  23. while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); }
  24. return ret*sig;
  25. }
  26. template<typename T>
  27. inline void read(T &x) {
  28. T ret=0, sig=1; char ch=0;
  29. while(ch<'0'||ch>'9') { if(ch=='-') sig=-1; ch=getchar(); }
  30. while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); }
  31. x = ret*sig;
  32. }
  33. template<typename T>
  34. inline void write(T x) {
  35. if(x<0) putchar('-'), x=-x;
  36. T stk[100], tt=0;
  37. do stk[tt++]=x%10, x/=10; while(x);
  38. while(tt) putchar(stk[--tt]+'0');
  39. }
  40. };
  41.  
  42. const int N = 10010;
  43. int n, m;
  44. int a[N];
  45.  
  46. int main() {
  47. #ifdef DEBUG
  48. OPEN(test);
  49. #endif
  50. OPEN(martian);
  51. IO::read(n), IO::read(m);
  52. for(register int i = 1; i<=n; ++i) IO::read(a[i]);
  53. for(register int i = 1; i<=m; ++i) next_permutation(a+1, a+1+n);
  54. for(register int i = 1; i<=n; ++i) IO::write(a[i]), putchar(' ');
  55. return 0;
  56. }