Advertisement
erfanul007

LOJ 1292

Apr 8th, 2021
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. // #include <iostream>
  3. // #include <cstdio>
  4. // #include <cstdlib>
  5. // #include <algorithm>
  6. // #include <cmath>
  7. // #include <vector>
  8. // #include <set>
  9. // #include <map>
  10. // #include <queue>
  11. // #include <stack>
  12. // #include <ctime>
  13. // #include <cassert>
  14. // #include <complex>
  15. // #include <string>
  16. // #include <cstring>
  17. // #include <bitset>
  18. using namespace std;
  19.  
  20. // #pragma GCC optimize("Ofast,no-stack-protector")
  21. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  22. // #pragma GCC optimize("unroll-loops")
  23.  
  24. #define ll              long long int
  25. #define vi              vector< int >
  26. #define vll             vector< ll >
  27.  
  28. #define sc              scanf
  29. #define pf              printf
  30. #define cspf(i)         pf("Case %d: ", i)
  31. #define spc             pf(" ")
  32. #define line            pf("\n")
  33.  
  34. #define ff              first
  35. #define ss              second
  36. #define mp              make_pair
  37. #define pb              push_back
  38. #define ppb             pop_back
  39. #define tp(v,j)         get<j>(v)
  40. #define Log(b,x)        (log(x)/log(b))
  41.  
  42. #define FOR(i,x,y)      for(int i = int(x); i < int(y); i++)
  43. #define ROF(i,x,y)      for(int i = int(x)-1; i >= int(y); i--)
  44. #define clr(arr,x)      memset(arr, x, sizeof arr)
  45. #define vout(v,sz)      for(int w=0;w<sz;w++){if(w) spc; cout<<v[w];}
  46. #define all(v)          v.begin(), v.end()
  47. #define rall(v)         v.rbegin(), v.rend()
  48. #define unq(v)          sort(all(v)),(v).resize(unique(all(v))-v.begin())
  49. #define fastIO          ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
  50.  
  51. #define sc1(x)          sc("%d",&x);
  52. #define sc2(x,y)        sc("%d %d", &x, &y)
  53. #define sc3(x,y,z)      sc("%d %d %d", &x, &y, &z)
  54. #define scl1(x)         sc("%lld",&x);
  55. #define scl2(x,y)       sc("%lld %lld", &x, &y)
  56. #define scf1(x)         sc("%lf",&x);
  57. #define scf2(x,y)       sc("%lf %lf", &x, &y)
  58.  
  59. #define pf1(x)          pf("%d",x);
  60. #define pf2(x,y)        pf("%d %d", x, y)
  61. #define pfl1(x)         pf("%lld",x);
  62. #define pfl2(x,y)       pf("%lld %lld", x, y)
  63.  
  64. #define MOD             (int)(998244353)
  65. #define MaxN            100000
  66. #define inf             0x3f3f3f3f
  67. #define PI              acos(-1.0)  // 3.1415926535897932
  68. #define eps             1e-9
  69.  
  70. #ifdef ERFANUL007
  71.     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
  72.     template < typename Arg1 >
  73.     void __f(const char* name, Arg1&& arg1){
  74.         cout << name << " = " << arg1 << std::endl;
  75.     }
  76.     template < typename Arg1, typename... Args>
  77.     void __f(const char* names, Arg1&& arg1, Args&&... args){
  78.         const char* comma = strchr(names, ',');
  79.         cout.write(names, comma - names) << " = " << arg1 <<" | ";
  80.         __f(comma+1, args...);
  81.     }
  82. #else
  83.     #define debug(...)
  84. #endif
  85.  
  86. template <class T> inline T bigMod(T p,T e,T M){T ret=1; for(;e>0;e>>=1){ if(e&1) ret=(ret*p)%M; p=(p*p)%M;} return (T)ret;}
  87. template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
  88. template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
  89. template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
  90.  
  91. int dx[] = { 1,-1, 0, 0};                //graph moves
  92. int dy[] = { 0, 0, 1,-1};               //graph moves
  93.  
  94. struct PT{
  95.     int x, y;
  96.     void scan(){ scanf("%d %d",&x,&y);}
  97. };
  98.  
  99.  
  100. double SQ(double x){ return x*x;}
  101.  
  102. double Dis(PT a,PT b){ return SQ(a.x - b.x) + SQ(a.y - b.y);}
  103.  
  104. double absDis(PT a,PT b){ return sqrt(Dis(a,b));}
  105.  
  106. /*two vector lines Dot product*/
  107. int Dot(PT a,PT b){ return a.x*b.x + a.y*b.y;}
  108.  
  109. /*two vector lines Cross product*/
  110. int Cross(PT a,PT b){ return a.x*b.y - b.x*a.y;}
  111.  
  112. /*convert degree to radian*/
  113. double toRadian(double x){ return (x*(PI/180.0));}
  114.  
  115. /*convert radian to degree*/
  116. double toDegree(double x){ return (x*(180.0/PI));}
  117.  
  118. /*two point's vector line*/
  119. PT vect(PT a,PT b){ return {a.x-b.x, a.y-b.y};}
  120.  
  121. /*convert a coordinate p from cartesian to polar
  122. r = sqrt(x*x + y*y)
  123. theta = atan(y/x) [in radian]*/
  124. // PT toPolar(PT p){
  125. //     return {sqrt(SQ(p.x)+SQ(p.y)), atan(p.y/p.x)};
  126. // }
  127.  
  128. /*convert a coordinate p from polar to cartesian
  129. theta must be radian
  130. x = r * cos(theta)
  131. y = r * sin(theta)*/
  132. // PT toCartesian(PT a){
  133. //     return {a.x * cos(a.y), a.x * sin(a.y)};
  134. // }
  135.  
  136. /*divide line ab into m:n and return midpoint*/
  137. /*For 3D add the z part same as x and y*/
  138. // PT divideLine(PT a, PT b, double m, double n){
  139. //     return {(a.x * m + b.x * n)/(m+n),
  140. //         (a.y * m + b.y * n)/(m+n)};
  141. // }
  142.  
  143. /*line ab to point c
  144. 0 => if ab and c coliner
  145. + => clockwise
  146. - => anticlockwise
  147. */
  148. int orientation(PT a, PT b, PT c)
  149. {
  150.     return (b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
  151. }
  152.  
  153. struct Rectangle
  154. {
  155.     int fig;
  156.     PT A, B, C, D;
  157.     void scan(int _fig){
  158.         A.scan();
  159.         C.scan();
  160.         B = {C.x, A.y};
  161.         D = {A.x, C.y};
  162.         fig = _fig;
  163.     }
  164.     bool inside(PT P){
  165.         int val1 = orientation(A, B, P);
  166.         int val2 = orientation(B, C, P);
  167.         int val3 = orientation(C, D, P);
  168.         int val4 = orientation(D, A, P);
  169.         if(val1 == val2 && val2 == val3 && val3 == val4) return true;
  170.         return false;
  171.     }
  172. };
  173.  
  174. struct Circle
  175. {
  176.     int fig;
  177.     PT A;
  178.     double r;
  179.     void scan(int _fig){
  180.         A.scan();
  181.         scanf("%lf", &r);
  182.         fig = _fig;
  183.     }
  184.     bool inside(PT P){
  185.         double dis = absDis(A, P);
  186.         if(dis + eps < r) return true;
  187.         return false;
  188.     }
  189. };
  190.  
  191. struct Triangle
  192. {
  193.     int fig;
  194.     PT A, B, C;
  195.     void scan(int _fig){
  196.         A.scan();
  197.         B.scan();
  198.         C.scan();
  199.         fig = _fig;
  200.     }
  201.     bool inside(PT P){
  202.         int val1 = orientation(A, B, P);
  203.         int val2 = orientation(B, C, P);
  204.         int val3 = orientation(C, A, P);
  205.         if(val1 == val2 && val2 == val3) return true;
  206.         return false;
  207.     }
  208. };
  209.  
  210. /*line ab and line cd is parrallel if ab X cd = 0 */
  211. bool ifParallel(PT a,PT b,PT c,PT d)
  212. {
  213.     if(Cross(vect(a,b),vect(c,d)) != 0) // for double abs(val) > eps
  214.         return false;
  215.     return true;
  216. }
  217.  
  218. /*line ab and line cd is perpendicular if ab . cd = 0 */
  219. bool ifPerpendicular(PT a,PT b,PT c,PT d)
  220. {
  221.     if(Dot(vect(a,b),vect(c,d)) != 0) // for double abs(val) > eps
  222.         return false;
  223.     return true;
  224. }
  225.  
  226. /*Area*/
  227.  
  228. double heronTriangle(double a, double b, double c){
  229.     double s = (a + b + c) / 2.0;
  230.     if(s - a < 0) return -1;
  231.     if(s - b < 0) return -1;
  232.     if(s - c < 0) return -1;
  233.     return sqrt(s * (s - a) * (s - b) * (s - c));
  234. }
  235.  
  236. double mdedianTriangle(double a, double b, double c){
  237.     double s = (a + b + c) / 2.0;
  238.     if(s - a < 0) return -1;
  239.     if(s - b < 0) return -1;
  240.     if(s - c < 0) return -1;
  241.     return (4.0 / 3.0 ) * sqrt(s * (s - a) * (s - b) * (s - c));
  242. }
  243.  
  244. double trapeziumArea(double a, double b, double h){
  245.     return (a + b) * h / 2.0;
  246. }
  247.  
  248. ///Area of irregular polygon
  249. double AreaOfPolygon(int n,PT a[])
  250. {
  251.     double area = 0.0;
  252.     for(int i=1;i<n;i++){
  253.         area+=(a[i-1].x*a[i].y-a[i].x*a[i-1].y);
  254.     }
  255.     area+=(a[n-1].x*a[0].y-a[0].x*a[n-1].y);
  256.     return area/2.0;
  257. }
  258.  
  259. /*volumn*/
  260.  
  261. double coneVolume(double r, double h){
  262.     return PI * r * r * h / 3.0;
  263. }
  264.  
  265. double CircumcircleR(double a, double b, double c){
  266.     if(a + b + c < eps) return 0;
  267.     return (a * b * c) / sqrt((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c));
  268. }
  269.  
  270. double IncircleR(double a, double b, double c){
  271.     if(a + b + c < eps) return 0;
  272.     return 2.0 * heronTriangle(a, b, c) / (a + b + c);
  273. }
  274.  
  275. bool insideRectangle(PT p, PT a, PT c){
  276.     if(p.x < a.x or p.x > c.x) return false;
  277.     if(p.y < a.y or p.y > c.y) return false;
  278.     return true;
  279. }
  280.  
  281. /*checking shapes*/
  282.  
  283. bool isSquare(PT *a){
  284.     if(abs(Dis(a[0], a[1]) - Dis(a[1], a[2])) > eps
  285.         or abs(Dis(a[1], a[2]) - Dis(a[2], a[3])) > eps
  286.         or abs(Dis(a[2], a[3]) - Dis(a[3], a[0])) > eps)
  287.         return false;
  288.     if(!ifPerpendicular(a[0], a[1], a[1], a[2])) return false;
  289.     return true;
  290. }
  291.  
  292. bool isRectangle(PT *a){
  293.     if(abs(Dis(a[0], a[1]) - Dis(a[3], a[2])) > eps
  294.         or abs(Dis(a[1], a[2]) - Dis(a[0], a[3])) > eps)
  295.         return false;
  296.     if(!ifPerpendicular(a[0], a[1], a[1], a[2])) return false;
  297.     return true;
  298. }
  299.  
  300. bool isRombus(PT *a){
  301.     if(abs(Dis(a[0], a[1]) - Dis(a[1], a[2])) > eps
  302.         or abs(Dis(a[1], a[2]) - Dis(a[2], a[3])) > eps
  303.         or abs(Dis(a[2], a[3]) - Dis(a[3], a[0])) > eps)
  304.         return false;
  305.     return true;
  306. }
  307.  
  308. bool isParallelogram(PT *a){
  309.     if(abs(Dis(a[0], a[1]) - Dis(a[3], a[2])) > eps
  310.         or abs(Dis(a[1], a[2]) - Dis(a[0], a[3])) > eps)
  311.         return false;
  312.     return true;
  313. }
  314.  
  315. bool isTrapezium(PT *a){
  316.     if(!ifParallel(a[0], a[1], a[3], a[2])
  317.         and !ifParallel(a[1], a[2], a[0], a[3])) return false;
  318.     return true;
  319. }
  320.  
  321.  
  322. PT f; //init first coordinate
  323. //for clockwise sorting
  324. bool ClockCmp(PT &a,PT &b){ return (f.x-a.x)*(f.y-b.y)<(f.x-b.x)*(f.y-a.y);}
  325.  
  326. //for anti-clockwise sorting
  327. bool AClockCmp(PT &a,PT &b){ return (f.x-a.x)*(f.y-b.y)>(f.x-b.x)*(f.y-a.y);}
  328.  
  329. int main()
  330. {
  331.     #ifndef ONLINE_JUDGE
  332.         clock_t tStart = clock();
  333.         freopen("input.txt", "r", stdin);
  334.         freopen("output.txt", "w", stdout);
  335.     #endif
  336.  
  337.     int t, ca=0; scanf("%d", &t);
  338.  
  339.     while(t--){
  340.         int n; scanf("%d", &n);
  341.         PT a[n];
  342.         for(int i=0; i<n; i++) a[i].scan();
  343.         int ans = 1;
  344.         if(n > 1) ans = 2;
  345.         for(int i=0; i<n-2; i++){
  346.             for(int j=i+1; j<n-1; j++){
  347.                 int cnt = 2;
  348.                 for(int k=j+1; k<n; k++){
  349.                     if(orientation(a[i], a[j], a[k]) == 0) cnt++;
  350.                 }
  351.                 ans = max(ans, cnt);
  352.             }
  353.         }
  354.         printf("Case %d: %d\n", ++ca, ans);
  355.     }
  356.  
  357.     #ifndef ONLINE_JUDGE
  358.         fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  359.     #endif
  360.  
  361.     return 0;
  362. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement