CSES - Aalto Competitive Programming 2024 - wk11 - Wed - Results
Submission details
Task:Match polygons
Sender:aalto2024l_002
Submission time:2024-11-20 17:46:30 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#90.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#120.00 sdetails
#130.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#200.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#280.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#330.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#360.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.01 sdetails
#430.00 sdetails
#44ACCEPTED0.00 sdetails
#45ACCEPTED0.00 sdetails
#46ACCEPTED0.00 sdetails
#47ACCEPTED0.00 sdetails
#480.00 sdetails
#49ACCEPTED0.00 sdetails
#50ACCEPTED0.00 sdetails
#51ACCEPTED0.00 sdetails
#520.00 sdetails
#53ACCEPTED0.00 sdetails
#54ACCEPTED0.00 sdetails
#55ACCEPTED0.00 sdetails
#560.00 sdetails
#57ACCEPTED0.00 sdetails
#580.00 sdetails
#59ACCEPTED0.00 sdetails
#60ACCEPTED0.00 sdetails
#61ACCEPTED0.01 sdetails
#62ACCEPTED0.01 sdetails
#630.01 sdetails
#64ACCEPTED0.01 sdetails
#65ACCEPTED0.01 sdetails
#66ACCEPTED0.01 sdetails
#67ACCEPTED0.01 sdetails
#680.01 sdetails
#69ACCEPTED0.01 sdetails
#700.01 sdetails
#71ACCEPTED0.21 sdetails
#720.21 sdetails
#730.21 sdetails
#74ACCEPTED0.21 sdetails
#75ACCEPTED0.21 sdetails

Code

#include <bits/stdc++.h>
using namespace std;

#define I_2D(row, col, width) ((row) * (width) + (col))
#define PRINT_ARR(arr, n)                                                      \
  do {                                                                         \
    for (int i = 0; i < n; i++) {                                              \
      cout << arr[i] << " ";                                                   \
    }                                                                          \
    cout << "\n";                                                              \
  } while (0)
#define PRINT_VEC_ARR(v, n)                                                    \
  do {                                                                         \
    for (int i = 0; i < n; i++) {                                              \
      cout << i << ": ";                                                       \
      for (auto item : v[i]) {                                                 \
        cout << item << " ";                                                   \
      }                                                                        \
      cout << endl;                                                            \
    }                                                                          \
  } while (0)
#define endl '\n';

typedef long long ll;
typedef complex<double> p;
#define X real()
#define Y imag()

#define ANG(a, b) arg(a / b)

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<p> points1(n);
  vector<vector<p>> v(2, vector<p>(n));
  vector<vector<double>> a(2, vector<double>(n));

  double x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    points1[i] = {x, y};
    if (i % n != 0) {
      v[0][i] = points1[i] - points1[i - 1];
    }
  }
  v[0][0] = points1[0] - points1[n - 1];

  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    points1[i] = {x, y};
    if (i % n != 0) {
      v[1][i] = points1[i] - points1[i - 1];
    }
  }
  v[1][0] = points1[0] - points1[n - 1];

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      a[0][i] = ANG(v[0][n - 1], v[0][i]);
      a[1][i] = ANG(v[1][n - 1], v[1][i]);
    } else {
      a[0][i] = ANG(v[0][(i - 1) % n], v[0][i]);
      a[1][i] = ANG(v[1][(i - 1) % n], v[1][i]);
    }
  }

  int index = 0;
  for (int i = 0; i < 2*n; i++) {
    if (index == n) {
      cout << "Yes" << endl;
      return 0;
    }
    if (abs(a[0][index] - a[1][i % n]) < 0.000001) {
      index++;
    } else {
      index = 0;
    }
  }

  cout << (index == n ? "Yes" : "No") << endl;

  return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
3
145.8941152374 -62.4127899333
215.1893651096 102.7633705745
44.8831775826 -76.3452030143
28.8949217210 68.0445638671
...

correct output
No

user output
No

Test 2

Verdict:

input
3
-197.6674322206 -353.244107216...

correct output
Yes

user output
No

Test 3

Verdict: ACCEPTED

input
3
-474.0737720427 49.6624761567
-169.6651796064 -295.351363915...

correct output
Yes

user output
Yes

Test 4

Verdict: ACCEPTED

input
3
10.8276009842 392.9469579759
396.2930912238 -374.4146840138
208.1478221972 -209.0952562075
-43.1667773180 149.1440517020
...

correct output
No

user output
No

Test 5

Verdict: ACCEPTED

input
3
214.8159946910 197.7288244779
47.2322534538 472.6843538631
-283.9104992809 476.2744547663
-71.1083540370 279.8609983382
...

correct output
Yes

user output
Yes

Test 6

Verdict: ACCEPTED

input
3
370.7323034888 -293.2808457801
111.7438615975 265.9078602206
418.6109044505 -11.5888097837
-426.5768989764 -0.3755815613
...

correct output
Yes

user output
Yes

Test 7

Verdict:

input
3
-168.0201953399 321.2291249562
-458.3033735249 -392.343323591...

correct output
Yes

user output
No

Test 8

Verdict: ACCEPTED

input
3
279.9187957373 -61.5907750747
38.4958717758 1.1204649377
223.4651800194 477.9895163271
-148.0958524894 -293.137314926...

correct output
Yes

user output
Yes

Test 9

Verdict:

input
3
30.8556874230 -267.2716731167
468.5406649977 369.1945386211
-488.6011964589 -69.5311823832
-76.7241898730 264.7261728057
...

correct output
Yes

user output
No

Test 10

Verdict: ACCEPTED

input
3
1.8745954997 -4.2267016836
-366.1704671086 -357.888907819...

correct output
Yes

user output
Yes

Test 11

Verdict: ACCEPTED

input
4
391.7730018258 463.6627640707
215.1893651096 102.7633705745
44.8831775826 -76.3452030143
145.8941152374 -62.4127899333
...

correct output
No

user output
No

Test 12

Verdict:

input
4
220.3244895202 -499.8856187024
-197.6674322206 -353.244107216...

correct output
Yes

user output
No

Test 13

Verdict:

input
4
-169.6651796064 -295.351363915...

correct output
Yes

user output
No

Test 14

Verdict: ACCEPTED

input
4
208.1478221972 -209.0952562075
-292.7571213710 -448.532791983...

correct output
No

user output
No

Test 15

Verdict: ACCEPTED

input
4
-283.9104992809 476.2744547663
214.8159946910 197.7288244779
47.2322534538 472.6843538631
-493.7697429619 -247.017638828...

correct output
Yes

user output
Yes

Test 16

Verdict: ACCEPTED

input
4
18.4179913146 -203.1995040629
370.7323034888 -293.2808457801
418.6109044505 -11.5888097837
111.7438615975 265.9078602206
...

correct output
Yes

user output
Yes

Test 17

Verdict: ACCEPTED

input
4
95.0520695152 29.8173602436
-81.1925694327 -164.5921507081
-168.0201953399 321.2291249562
-458.3033735249 -392.343323591...

correct output
Yes

user output
Yes

Test 18

Verdict: ACCEPTED

input
4
223.4651800194 477.9895163271
38.4958717758 1.1204649377
-427.9488664850 -231.561013865...

correct output
Yes

user output
Yes

Test 19

Verdict: ACCEPTED

input
4
-97.6486388207 22.6746672769
-488.6011964589 -69.5311823832
30.8556874230 -267.2716731167
468.5406649977 369.1945386211
...

correct output
No

user output
No

Test 20

Verdict:

input
4
-281.4413257844 -81.4918140235
-251.8988265336 -415.940346164...

correct output
Yes

user output
No

Test 21

Verdict: ACCEPTED

input
5
-116.5584786160 291.7250335397
215.1893651096 102.7633705745
44.8831775826 -76.3452030143
145.8941152374 -62.4127899333
...

correct output
No

user output
No

Test 22

Verdict: ACCEPTED

input
5
220.3244895202 -499.8856187024
38.8167321066 -80.8054807488
-154.4392748298 -103.232531186...

correct output
Yes

user output
Yes

Test 23

Verdict: ACCEPTED

input
5
119.2709705091 -200.3453226946
-169.6651796064 -295.351363915...

correct output
Yes

user output
Yes

Test 24

Verdict: ACCEPTED

input
5
396.2930912238 -374.4146840138
-292.7571213710 -448.532791983...

correct output
No

user output
No

Test 25

Verdict: ACCEPTED

input
5
214.8159946910 197.7288244779
47.2322534538 472.6843538631
-65.2084702386 279.3829260936
-493.7697429619 -247.017638828...

correct output
No

user output
No

Test 26

Verdict: ACCEPTED

input
5
418.6109044505 -11.5888097837
111.7438615975 265.9078602206
18.4179913146 -203.1995040629
-312.2787736378 -419.258730996...

correct output
Yes

user output
Yes

Test 27

Verdict: ACCEPTED

input
5
95.0520695152 29.8173602436
-458.3033735249 -392.343323591...

correct output
No

user output
No

Test 28

Verdict:

input
5
223.4651800194 477.9895163271
279.9187957373 -61.5907750747
-0.1175014731 179.2299907021
-427.9488664850 -231.561013865...

correct output
Yes

user output
No

Test 29

Verdict: ACCEPTED

input
5
-488.6011964589 -69.5311823832
-97.6486388207 22.6746672769
-21.6082081031 55.3564750418
468.5406649977 369.1945386211
...

correct output
No

user output
No

Test 30

Verdict: ACCEPTED

input
5
-366.1704671086 -357.888907819...

correct output
Yes

user output
Yes

Test 31

Verdict: ACCEPTED

input
10
215.1893651096 102.7633705745
370.0121452893 478.6183430976
332.6198429261 278.1567571119
-412.8707029537 -479.781600728...

correct output
No

user output
No

Test 32

Verdict: ACCEPTED

input
10
-197.6674322206 -353.244107216...

correct output
Yes

user output
Yes

Test 33

Verdict:

input
10
29.1420905428 -365.4200575121
13.5781179412 -315.5601370179
285.3351476881 353.9752909584
-5.7631594720 346.5614913514
...

correct output
Yes

user output
No

Test 34

Verdict: ACCEPTED

input
10
396.2930912238 -374.4146840138
10.8276009842 392.9469579759
208.1478221972 -209.0952562075
-84.8988037551 -216.4749136305
...

correct output
No

user output
No

Test 35

Verdict: ACCEPTED

input
10
214.8159946910 197.7288244779
-283.9104992809 476.2744547663
-493.7697429619 -247.017638828...

correct output
No

user output
No

Test 36

Verdict:

input
10
418.6109044505 -11.5888097837
370.7323034888 -293.2808457801
79.8378087402 99.9291982716
-203.9200667946 128.7879072777
...

correct output
Yes

user output
No

Test 37

Verdict: ACCEPTED

input
10
323.7594305076 -445.5254961601
-86.7990650067 376.2676519525
490.2242714829 319.8581971028
78.8586054090 145.3550910008
...

correct output
No

user output
No

Test 38

Verdict: ACCEPTED

input
10
279.9187957373 -61.5907750747
-475.1007730927 100.5489220262
-47.8760438631 431.2060235370
409.5935271290 -286.6146460422
...

correct output
Yes

user output
Yes

Test 39

Verdict: ACCEPTED

input
10
468.5406649977 369.1945386211
-281.1989388303 -434.191608273...

correct output
No

user output
No

Test 40

Verdict: ACCEPTED

input
10
-461.2516256201 199.1073919851
378.5590828200 450.9640294998
-154.5013572565 -333.223648952...

correct output
Yes

user output
Yes

Test 41

Verdict: ACCEPTED

input
100
-361.8170504185 -303.417643118...

correct output
No

user output
No

Test 42

Verdict: ACCEPTED

input
100
33.1652894178 191.8771127699
-184.4843660273 186.5009246725
334.6256736627 -481.7117197876
250.1443123990 488.8610876221
...

correct output
Yes

user output
Yes

Test 43

Verdict:

input
100
418.4586408585 92.0845730713
-153.7620872729 -236.221473534...

correct output
Yes

user output
No

Test 44

Verdict: ACCEPTED

input
100
448.5276483394 200.5117812008
251.0273075753 -156.9061412350
-269.1637320891 465.2933520511
34.7348709576 274.9678181440
...

correct output
No

user output
No

Test 45

Verdict: ACCEPTED

input
100
490.7968171326 -426.3476238374
-90.4086108461 262.8817904577
51.9264361054 -319.0351620088
425.8085958464 220.4521208745
...

correct output
No

user output
No

Test 46

Verdict: ACCEPTED

input
100
-74.3626661635 -76.1504015282
-181.3535649091 -134.666982828...

correct output
Yes

user output
Yes

Test 47

Verdict: ACCEPTED

input
100
168.1377296396 438.3926027826
286.0058594120 250.4304716281
-2.9490289955 -457.2674989056
316.8674938575 -486.3762628636
...

correct output
No

user output
No

Test 48

Verdict:

input
100
-350.5137011789 -476.809635525...

correct output
Yes

user output
No

Test 49

Verdict: ACCEPTED

input
100
-200.9472548840 365.4240335970
346.9465387115 -34.2996311811
251.3582001296 283.5706742682
-131.9031523480 -322.686901620...

correct output
No

user output
No

Test 50

Verdict: ACCEPTED

input
100
-363.3269953958 -83.5422447588
238.4628330597 84.3076344610
383.4332256402 78.7496102147
-322.0295442938 91.7516883536
...

correct output
Yes

user output
Yes

Test 51

Verdict: ACCEPTED

input
200
-172.2796022472 256.7786464273
136.0610565234 -259.9797261107
-339.4611774089 296.3914747838
459.1666030018 -41.8611750396
...

correct output
No

user output
No

Test 52

Verdict:

input
200
33.1652894178 191.8771127699
-184.4843660273 186.5009246725
334.6256736627 -481.7117197876
250.1443123990 488.8610876221
...

correct output
Yes

user output
No

Test 53

Verdict: ACCEPTED

input
200
200.7523435514 464.5510825450
80.0041831077 -337.7013967560
-113.1073493364 293.6374527898
-16.9301681094 5.2367171257
...

correct output
Yes

user output
Yes

Test 54

Verdict: ACCEPTED

input
200
360.5339118870 86.2529018574
-208.2072264492 -42.3136017743
-31.0597544157 -230.7644195975
-274.9454972746 -93.4800828538
...

correct output
No

user output
No

Test 55

Verdict: ACCEPTED

input
200
-478.6701591848 83.9198708060
-54.6429558156 342.0566538501
-300.9443485300 -59.4009511125
167.4545291040 -431.6653725926
...

correct output
No

user output
No

Test 56

Verdict:

input
200
49.4634593109 207.5262226064
-234.8873378290 -490.291688824...

correct output
Yes

user output
No

Test 57

Verdict: ACCEPTED

input
200
-194.4127520360 177.9625888294
135.4779960658 224.4061120463
-241.0205240694 -223.200325023...

correct output
No

user output
No

Test 58

Verdict:

input
200
-42.4011263057 395.3667842530
-442.7464391228 57.3176247339
-172.0889013916 -464.726660462...

correct output
Yes

user output
No

Test 59

Verdict: ACCEPTED

input
200
-399.6132030797 231.1584326536
-349.0298947219 36.1443047518
127.0556495233 -284.6822030259
-53.5770931326 -311.8274867595
...

correct output
No

user output
No

Test 60

Verdict: ACCEPTED

input
200
417.0287554196 194.5884938677
-363.9202956245 307.6956033342
-26.4321239562 -58.3468212421
-298.9623330859 404.6753463722
...

correct output
Yes

user output
Yes

Test 61

Verdict: ACCEPTED

input
1000
-169.4036997070 -448.946934805...

correct output
No

user output
No

Test 62

Verdict: ACCEPTED

input
1000
345.5176757164 320.2024696845
408.8080319057 -349.3100103728
-315.0649811086 65.7321453399
374.7476191883 202.9317391843
...

correct output
Yes

user output
Yes

Test 63

Verdict:

input
1000
219.6875435643 213.0072901918
269.8596571543 -169.2529716435
-271.3897492748 126.3439621773
-85.5207510408 436.7810746595
...

correct output
Yes

user output
No

Test 64

Verdict: ACCEPTED

input
1000
-360.5328729828 -186.180887851...

correct output
No

user output
No

Test 65

Verdict: ACCEPTED

input
1000
474.3704468638 -39.4976558160
-140.9809366535 -399.686457453...

correct output
No

user output
No

Test 66

Verdict: ACCEPTED

input
1000
436.9671382620 271.4579197691
279.0135301573 -485.3562019434
192.8559481123 -465.6796370956
254.8746088172 -75.0699801116
...

correct output
Yes

user output
Yes

Test 67

Verdict: ACCEPTED

input
1000
-187.5982099198 229.8238792093
3.5532439404 -456.8527777580
-208.7357286799 139.8281083868
468.5752076857 318.3348546534
...

correct output
No

user output
No

Test 68

Verdict:

input
1000
348.1110838687 186.1280973285
-126.3758471551 -407.922449821...

correct output
Yes

user output
No

Test 69

Verdict: ACCEPTED

input
1000
-386.0740098833 93.3802332762
-274.4602815315 187.5615193622
-13.4234250797 191.5405241327
-423.5354565059 50.7549107200
...

correct output
No

user output
No

Test 70

Verdict:

input
1000
-451.1004626587 149.3426100968
-211.2764645506 344.4102345563
-166.7031335983 421.3069957702
-368.6133048856 49.0049880385
...

correct output
Yes

user output
No

Test 71

Verdict: ACCEPTED

input
100000
-205.3245172610 -151.443930911...

correct output
No

user output
No

Test 72

Verdict:

input
100000
-96.6377474657 -267.3024156647
378.2164754911 315.8208359125
-382.8506882809 -109.238752477...

correct output
Yes

user output
No

Test 73

Verdict:

input
100000
171.1064190127 422.2639523115
-103.5929075564 480.2294932552
-126.3506574590 126.1145421587
-283.4265770635 -221.357530439...

correct output
Yes

user output
No

Test 74

Verdict: ACCEPTED

input
100000
-430.5032134612 -451.506257934...

correct output
No

user output
No

Test 75

Verdict: ACCEPTED

input
100000
-462.9306928679 -454.709734504...

correct output
No

user output
No