fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long maximum(long a,long b)
  5. {
  6. if(a>b)
  7. return a;
  8. else
  9. return b;
  10. }
  11.  
  12. long modd(long a)
  13. {
  14. if(a<0)
  15. return -a;
  16. else
  17. return a;
  18. }
  19. int main() {
  20.  
  21. long t;
  22. cin>>t;
  23. for(long i=0;i<t;i++)
  24. {
  25. long n,m;
  26. cin>>n>>m;
  27. long leftMax=0,rightMax=0;
  28. for(long j=0;j<m;j++)
  29. {
  30. long input;
  31. cin>>input;
  32. if(input>leftMax)
  33. leftMax=input;
  34. if(n-input-1>rightMax)
  35. rightMax=n-input-1;
  36. }
  37. if(n==1)
  38. cout<<leftMax<<"\n";
  39. else
  40. {
  41. cout<<leftMax;
  42. for(long j=1;j<n-1;j++)
  43. {
  44. cout<<maximum(modd(leftMax-j),modd(rightMax-(n-j-1)));
  45. }
  46. cout<<rightMax<<"\n";
  47. }
  48. }
  49. return 0;
  50. }
Success #stdin #stdout 0s 2688KB
stdin
2
4 1
1
6 2
2 3
stdout
1012
321123