fork(9) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <math.h>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <string.h>
  7. #include <set>
  8. #include <map>
  9. #include <bitset>
  10. #include <time.h>
  11. using namespace std;
  12.  
  13. typedef vector <int> vi;
  14.  
  15. #define ll long long
  16. #define pb push_back
  17. #define ld double
  18. #define pld pair <ld, ld>
  19. #define pll pair <ll, ll>
  20. #define fi first
  21. #define pii pair <int, int>
  22. #define se second
  23. #define mp make_pair
  24.  
  25. pii a[1000];
  26. int ans[1000][1000];
  27. int main()
  28. {
  29. //freopen("subsequences.in", "r", stdin);
  30. //freopen("subsequences.out", "w", stdout);
  31. // freopen("input.txt", "r", stdin);
  32. // freopen("output.txt", "w", stdout);
  33. ios_base::sync_with_stdio(false);
  34. int n;
  35. cin >> n;
  36. for (int i = 0; i < n; i++)
  37. {
  38. cin >> a[i].fi;
  39. a[i].se = i;
  40. }
  41. for (int i = 0; i < n; i++)
  42. {
  43. sort(a + i, a + n);
  44. int j = 0;
  45. for (j = i + 1; (j < n) && a[i].fi > 0; j++)
  46. a[i].fi--,
  47. a[j].fi--,
  48. ans[a[i].se][a[j].se] = 1,
  49. ans[a[j].se][a[i].se] = 1;
  50. for (; j < n; j++)
  51. a[j].fi -= 2,
  52. ans[a[i].se][a[j].se] = 0,
  53. ans[a[j].se][a[i].se] = 2;
  54.  
  55.  
  56. }
  57. for (int i = 0; i < n; i++)
  58. {
  59. for (int j = 0; j < n; j++)
  60. {
  61. cout << ans[i][j] << " ";
  62. }
  63. cout << endl;
  64. }
  65. return 0;
  66.  
  67. }
  68.  
  69.  
  70.  
Runtime error #stdin #stdout 0s 7148KB
stdin
Standard input is empty
stdout
Standard output is empty