fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <queue>
  8. #include <stack>
  9. #include <utility>
  10. #include <sstream>
  11. #include <map>
  12. #include <set>
  13. #include <ctime>
  14. using namespace std;
  15.  
  16. typedef long long LL;
  17. typedef vector<int> VI;
  18. typedef vector<VI> VVI;
  19. typedef pair<int,int> PI;
  20.  
  21. const int inf=2000000000;
  22. const LL INF=LL(inf)*inf;
  23. const LL mod=1000000007LL;
  24. double eps=1e-8;
  25.  
  26. #define mp make_pair
  27. #define pb push_back
  28. #define sc(x) scanf("%d",&(x))
  29. #define MAXN 100001
  30. struct Point
  31. {
  32. int x;
  33. int y;
  34. };
  35.  
  36. // To find orientation of ordered triplet (p, q, r).
  37. // The function returns following values
  38. // 0 --> p, q and r are colinear
  39. // 1 --> Clockwise
  40. // 2 --> Counterclockwise
  41. int orientation(Point p, Point q, Point r)
  42. {
  43. // See 10th slides from following link for derivation of the formula
  44. // http://w...content-available-to-author-only...c.uk/~pat/52233/slides/Geometry1x1.pdf
  45. int val = (q.y - p.y) * (r.x - q.x) -
  46. (q.x - p.x) * (r.y - q.y);
  47.  
  48. if (val == 0) return 0; // colinear
  49.  
  50. return (val > 0)? 1: 2; // clock or counterclock wise
  51. }
  52.  
  53. int main()
  54. {
  55. int t,n,i,j,x,y;
  56. freopen("input.txt","w",stdout);
  57. n=50;
  58. printf("%d\n",n);
  59. srand(time(NULL));
  60. Point p,p1,p2;
  61. int A[101][101]={{0}};
  62. int count=0;
  63. vector<Point> v;
  64. int coord=100;
  65. while(count<n)
  66. {
  67. x=rand()%coord;
  68. y=rand()%coord;
  69. if(A[x][y]==0)
  70. {
  71. //printf("%d %d\n",x,y);
  72. p.x=x;p.y=y;
  73. for(j=0;j<v.size();j++)
  74. {
  75. for(int k=j+1;k<v.size();k++)
  76. {
  77. if(orientation(p,v[j],v[k])==0)
  78. goto collinear;
  79. }
  80. }
  81. A[p.x][p.y]=1;
  82. count++;
  83. v.pb(p);
  84. }
  85. collinear:{}
  86. }
  87. //printf("input:\n");
  88. char S[n][n];
  89. for(i=0;i<n;i++)
  90. S[i][i]='N';
  91. for(i=0;i<n;i++)
  92. {
  93. for(j=i+1;j<n;j++)
  94. {
  95. t=rand()%3;
  96. if(t==2)
  97. S[i][j]='N';
  98. else
  99. S[i][j]='Y';
  100. S[j][i]=S[i][j];
  101. }
  102. }
  103. for(i=0;i<v.size() ;i++)
  104. cout<<v[i].x<<" "<<v[i].y<<endl;
  105. //printf("%d %d\n",v[i].x,v[i].y);
  106. for(i=0;i<n;i++)
  107. {
  108. for(j=0;j<n;j++)
  109. printf("%c",S[i][j]);
  110. printf("\n");
  111. }
  112. fclose(stdout);
  113. }
  114.  
  115.  
  116.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Standard output is empty