QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245019#7680. Subwayckiseki#AC ✓1ms3652kbC++204.0kb2023-11-09 17:53:212023-11-09 17:53:22

Judging History

你现在查看的是最新测评结果

  • [2023-11-09 17:53:22]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3652kb
  • [2023-11-09 17:53:21]
  • 提交

answer

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

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  for (int f = 0; L != R; L++)
    cerr << (f++ ? ", " : "") << *L;
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

class SVG {
  void p(string_view s) { o << s; }
  void p(string_view s, auto v, auto... vs) {
    auto i = s.find('$');
    o << s.substr(0, i) << v, p(s.substr(i + 1), vs...);
  }
  ofstream o;
  string c = "red";
public:
  SVG(auto f, auto x1, auto y1, auto x2, auto y2) : o(f) {
    p("<svg xmlns='http://www.w3.org/2000/svg' viewBox='$ $ $ $'>\n"
      "<style>*{stroke-width:0.5%;}</style>\n",
      x1, -y2, x2 - x1, y2 - y1); 
  }
  ~SVG() { p("</svg>\n"); }
  SVG &color(string nc) { return c = nc, *this; }
  void line(auto x1, auto y1, auto x2, auto y2) {
    p("<line x1='$' y1='$' x2='$' y2='$' stroke='$'/>\n",
      x1, -y1, x2, -y2, c); 
  }
};

constexpr int R = 1'000'000'000;

using lld = int64_t;

void exgcd(lld x, lld y, lld &a, lld &b) {
  if (y == 0) a = 1, b = 0;
  else exgcd(y, x % y, b, a), b -= (x / y) * a;
}

pair<lld, lld> MakeMid(lld a, lld b, lld v) {
  lld x, y;
  exgcd(a, b, x, y);
  lld vv = v % abs(a);
  x *= vv, y *= vv;
  return {x + v / abs(a), y};
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  mt19937 rnd(7122);
  uniform_int_distribution<lld> C(-10'000, 10'000);
  int n;
  cin >> n;
  if (n == 1) {
    int x, y, c;
    cin >> x >> y >> c;
    cout << c << '\n';
    for (int i = 0; i < c; ++i) {
      cout << 2 << ' ' << x << ' ' << y;
      cout << ' ' << x + i  << ' ' << y + i + 1 << '\n';
    }
    return 0;
  }
  vector<tuple<lld, lld, int>> v_(n);
  for (auto &[x, y, c] : v_)
    cin >> x >> y >> c;
  while (true) {
    lld a = C(rnd), b = C(rnd);
    if (a == 0 and b == 0)
      continue;
    lld g = gcd(abs(a), abs(b));
    a /= g, b /= g;

    auto v = v_;

    auto f = [&](lld x, lld y) {
      return a * x + b * y;
    };

    sort(v.begin(), v.end(), [&](const auto &lhs, const auto &rhs) {
      return f(get<0>(lhs), get<1>(lhs)) < f(get<0>(rhs), get<1>(rhs));
    });
    bool valid = true;
    for (int i = 1; i < n; ++i) {
      valid &= f(get<0>(v[i]), get<1>(v[i])) - f(get<0>(v[i - 1]), get<1>(v[i - 1])) > 1;
    }
    if (not valid)
      continue;
    vector<pair<lld, lld>> mid;
    for (int i = 0; i + 1 < n; ++i) {
      const auto [x1, y1, _] = v[i];
      lld fv = f(x1, y1) + 1;
      auto [x2, y2] = MakeMid(a, b, fv);
      mid.emplace_back(x2, y2);
    }
    vector<vector<pair<lld, lld>>> ans;
    while (true) {
      bool all0 = true;
      for (auto [_, __, c] : v)
        all0 &= c == 0;
      if (all0)
        break;
      ans.push_back({});
      for (int i = 0; i < n; ++i) {
        auto &[x, y, c] = v[i];
        if (c == 0) { 
          x -= b, y += a;
        } else {
          c -= 1;
        }
        ans.back().emplace_back(x, y);
        if (i + 1 < n) {
          ans.back().push_back(mid[i]);
          mid[i].first -= b;
          mid[i].second += a;
        }
      }
    }
    for (const auto &ansi : ans) {
      for (auto [x, y] : ansi) {
        valid &= -R <= x and x <= R;
        valid &= -R <= y and y <= R;
      }
    }
    if (not valid)
      continue;

    //SVG svg("d.svg", -1e5, -1e5, 1e5, 1e5);
    cout << ans.size() << '\n';
    for (const auto &ansi : ans) {
      cout << ansi.size();
      for (auto [x, y] : ansi) {
        cout << ' ' << x << ' ' << y;
      }
      cout << '\n';

      //for (size_t i = 1; i < ansi.size(); ++i) {
      //  auto [x1, y1] = ansi[i - 1];
      //  auto [x2, y2] = ansi[i];
      //  svg.line(x1, y1, x2, y2);
      //}
    }
    break;
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3476kb

input:

3
1 2 1
2 1 2
3 3 2

output:

2
5 1 2 -21420 -32040 3 3 63665 95230 2 1
5 360 539 -21061 -31503 3 3 64024 95767 2 1

result:

ok ok Sum L = 10

Test #2:

score: 0
Accepted
time: 1ms
memory: 3400kb

input:

1
1 1 1

output:

1
2 1 1 1 2

result:

ok ok Sum L = 2

Test #3:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

1
1 1 50

output:

50
2 1 1 1 2
2 1 1 2 3
2 1 1 3 4
2 1 1 4 5
2 1 1 5 6
2 1 1 6 7
2 1 1 7 8
2 1 1 8 9
2 1 1 9 10
2 1 1 10 11
2 1 1 11 12
2 1 1 12 13
2 1 1 13 14
2 1 1 14 15
2 1 1 15 16
2 1 1 16 17
2 1 1 17 18
2 1 1 18 19
2 1 1 19 20
2 1 1 20 21
2 1 1 21 22
2 1 1 22 23
2 1 1 23 24
2 1 1 24 25
2 1 1 25 26
2 1 1 26 27
2 ...

result:

ok ok Sum L = 100

Test #4:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

50
662 -567 48
728 -120 7
307 669 27
-885 -775 21
100 242 9
-784 -537 41
940 198 46
736 -551 30
-449 456 16
-945 382 18
-182 810 49
213 187 44
853 245 48
617 -305 19
-81 261 3
617 208 8
-548 -652 6
-888 -667 14
-371 -812 43
202 -702 10
-668 -725 5
961 -919 33
-870 -697 50
428 810 29
560 405 7
348 -3...

output:

50
99 -926 671 -38502 -55536 -945 382 -25238 -35956 -683 731 -45439 -66216 -558 825 -35262 -51086 -825 381 -46299 -67640 -981 -193 -62969 -92916 -449 456 -54898 -80990 -182 810 -33091 -48416 -331 176 -42574 -63012 -888 -667 -6154 -8544 -784 -537 -64208 -95408 -870 -697 -2546 -3204 190 864 -39181 -58...

result:

ok ok Sum L = 4950

Test #5:

score: 0
Accepted
time: 1ms
memory: 3456kb

input:

50
-772 697 1
-756 -909 1
659 923 1
850 471 1
260 -24 1
473 -639 1
-575 393 1
-466 197 1
333 -637 1
-192 -890 1
103 546 1
749 -723 1
-573 613 1
214 -138 1
277 928 1
266 291 1
911 275 1
-680 -67 1
69 190 1
-197 -795 1
684 618 1
729 -115 1
-658 -229 1
-595 -470 1
898 -172 1
401 81 1
133 685 1
223 400 ...

output:

1
99 -772 697 -62760 -92026 -530 890 -64313 -94518 -532 838 -15491 -21538 -573 613 -52509 -77074 -304 897 -43624 -63902 -389 708 -21092 -30260 -575 393 -47485 -69776 -254 815 -55062 -81168 -187 841 -15505 -22072 -346 458 -12433 -17622 -680 -67 -13844 -19758 -666 -82 -12035 -17088 -466 197 -45222 -66...

result:

ok ok Sum L = 99

Test #6:

score: 0
Accepted
time: 1ms
memory: 3496kb

input:

50
-56 747 3
993 -490 4
930 -139 1
-298 -330 1
938 -351 5
-973 100 5
-472 44 4
345 628 5
481 -91 4
789 581 5
457 -29 4
871 -799 1
692 994 4
699 854 2
893 -33 1
-483 256 3
-962 -540 2
846 -893 1
830 609 5
845 -383 2
-552 -966 1
-544 -51 1
564 186 4
-615 -675 1
618 -911 3
-561 -302 4
-293 667 3
-334 -...

output:

5
99 -999 330 -40370 -58562 -842 381 -46316 -67640 -973 100 -55422 -81346 -104 972 -52399 -77252 -293 667 -58691 -86686 -483 256 -9698 -13528 -962 -540 -64027 -94874 -159 609 -9015 -12638 -56 747 -25426 -37202 -544 -51 -58224 -86330 -472 44 -26919 -39516 -888 -613 -12616 -18156 -364 169 -63070 -9362...

result:

ok ok Sum L = 495

Test #7:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

50
600 997 5
-893 -204 3
408 443 1
-560 -748 7
-647 161 6
-285 -980 1
87 -582 7
-48 -721 7
997 285 2
-189 -728 8
525 222 4
-324 816 9
760 317 3
753 -480 10
-813 -921 3
-325 -875 8
-747 816 10
-627 605 7
775 786 6
136 -54 2
274 948 10
216 -113 7
924 68 3
101 576 8
60 -501 2
898 801 8
-767 -974 10
-99...

output:

10
99 -980 753 -27068 -38270 -747 816 -34374 -49484 -627 605 -30305 -43788 -324 816 -33951 -49484 -982 -212 -18095 -25810 -419 564 -3890 -4628 -972 -312 -27419 -39872 -893 -204 -40264 -59096 -647 161 -41095 -60342 -99 819 -34085 -50018 -215 624 -10866 -15308 -805 -304 -49510 -73158 -660 -335 -3054 -...

result:

ok ok Sum L = 990

Test #8:

score: 0
Accepted
time: 1ms
memory: 3572kb

input:

50
24 -889 49
117 418 49
25 524 44
980 -416 43
-494 357 41
-287 -285 46
151 574 41
-289 68 49
-515 -540 41
-367 -178 47
-887 151 45
197 -272 47
714 724 45
-737 94 49
810 830 47
808 -695 41
537 -637 49
-142 -167 44
-749 -631 47
445 -444 42
801 910 43
59 363 42
-912 466 50
-649 -479 48
-958 -511 49
88...

output:

50
99 -998 343 -20624 -29014 -912 466 -35257 -50908 -615 809 -54705 -80100 -486 866 -61397 -90246 -887 151 -61439 -90424 -737 94 -54468 -80278 -868 -114 -51009 -75116 -195 889 -21257 -30616 -308 652 -56911 -84016 -494 357 -43096 -63368 -958 -511 -24892 -36312 -127 643 -55653 -82414 -786 -384 -18617 ...

result:

ok ok Sum L = 4950

Test #9:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

50
151 -171 50
-367 -951 50
808 569 50
150 -618 50
27 -476 50
-846 729 50
549 -456 50
50 646 50
294 -70 50
-571 104 50
128 -265 50
913 -700 50
267 -965 50
896 846 50
-2 713 50
21 679 50
-515 975 50
168 180 50
-369 -98 50
676 115 50
643 -779 50
920 -237 50
-324 450 50
149 -378 50
-882 -602 50
-126 -7...

output:

50
99 -846 729 -24062 -33998 -841 601 -51341 -74938 -515 975 -53169 -77786 -501 927 -47411 -69242 -851 279 -34119 -49484 -474 780 -29793 -43076 -544 307 -15862 -22606 -571 104 -34198 -50196 -324 450 -54055 -79922 -604 -168 -44283 -65504 -882 -602 -35227 -51976 -2 713 -42604 -63012 21 679 -59813 -888...

result:

ok ok Sum L = 4950

Test #10:

score: 0
Accepted
time: 1ms
memory: 3560kb

input:

50
4 5 34
1 -5 24
-4 -4 32
-3 3 28
0 -1 21
1 -4 25
0 0 30
0 -4 42
-3 -2 44
-5 -3 37
4 -1 46
5 2 20
2 2 37
-2 5 35
-2 -1 39
2 4 32
-4 -3 42
0 3 32
3 5 47
-4 1 2
5 -1 17
-5 -4 5
-2 2 29
-5 1 11
2 -5 43
4 4 14
-5 0 9
0 -5 17
5 1 27
-3 0 24
-1 4 16
5 0 50
3 -2 18
1 -2 6
2 -1 29
-1 3 38
1 5 36
-3 1 28
-3...

output:

50
99 -3 5 -21783 -32574 -5 1 -42607 -63724 -2 5 -21782 -32574 -3 3 -243 -356 -5 0 -63788 -95408 -4 1 -42606 -63724 -1 5 -21781 -32574 -1 4 -42962 -64258 -3 1 -42605 -63724 0 5 -21780 -32574 -2 2 -21423 -32040 -1 3 -241 -356 -3 0 -63786 -95408 -5 -3 -63429 -94874 1 5 -21779 -32574 -3 -1 -21065 -3150...

result:

ok ok Sum L = 4950

Test #11:

score: 0
Accepted
time: 1ms
memory: 3436kb

input:

50
2 0 2
2 -3 2
4 1 2
-3 -3 2
-5 1 2
5 3 2
-5 -3 2
-3 -2 2
2 -1 2
2 3 2
4 4 1
1 -4 1
5 -1 2
-4 1 2
3 -2 1
-1 2 2
5 -5 2
-2 1 2
-5 -1 2
-2 -1 2
-1 -2 2
5 5 1
0 -2 2
1 1 1
2 2 2
3 5 2
-2 -4 1
-3 5 1
4 2 2
-4 -4 2
-3 2 1
5 0 2
-2 -2 2
-4 4 1
-2 5 2
2 5 1
3 -5 2
-4 5 2
-5 5 2
-2 4 2
-5 -5 2
-2 2 2
-3 -4...

output:

2
99 -5 5 -21785 -32574 -4 5 -21784 -32574 -4 4 -42965 -64258 -3 5 -21783 -32574 -5 1 -42607 -63724 -2 5 -21782 -32574 -2 4 -42963 -64258 -4 1 -42606 -63724 -3 2 -21424 -32040 -5 -1 -21067 -31506 -2 2 -21423 -32040 -3 0 -63786 -95408 -5 -3 -63429 -94874 -2 1 -42604 -63724 -1 2 -21422 -32040 -3 -2 -4...

result:

ok ok Sum L = 198

Test #12:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

50
4 3 49
-5 -3 49
0 -3 50
-2 -4 49
-5 -5 50
4 0 49
-1 -2 49
-2 0 49
1 2 50
-1 -5 50
-5 -1 50
-5 5 49
2 0 50
-2 -3 50
-4 -5 50
0 -2 50
-5 4 50
-1 1 49
-1 -4 49
-3 -1 49
1 -3 50
-4 1 50
0 5 50
1 -2 50
-1 5 50
4 2 50
4 -3 49
1 -4 49
-1 -1 49
-3 -5 50
4 -4 50
3 2 49
3 -3 49
0 2 50
-3 -4 49
5 -1 49
-3 5...

output:

50
99 -5 5 -21785 -32574 -5 4 -42966 -64258 -4 4 -42965 -64258 -3 5 -21783 -32574 -4 1 -42606 -63724 -1 5 -21781 -32574 -5 -1 -21067 -31506 -2 3 -242 -356 0 5 -21780 -32574 -5 -3 -63429 -94874 0 4 -42961 -64258 -3 -1 -21065 -31506 -2 0 -63785 -95408 1 4 -42960 -64258 -1 1 -42603 -63724 -5 -5 -41889 ...

result:

ok ok Sum L = 4950

Test #13:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

50
114 514 30
115 514 41
116 514 6
117 514 49
118 514 10
119 514 49
120 514 1
121 514 7
122 514 3
123 514 4
124 514 1
125 514 12
126 514 15
127 514 16
128 514 34
129 514 24
130 514 49
131 514 43
132 514 25
133 514 12
134 514 26
135 514 13
136 514 12
137 514 15
138 514 7
139 514 25
140 514 5
141 514 ...

output:

49
99 114 514 -39975 -59452 115 514 -39974 -59452 116 514 -39973 -59452 117 514 -39972 -59452 118 514 -39971 -59452 119 514 -39970 -59452 120 514 -39969 -59452 121 514 -39968 -59452 122 514 -39967 -59452 123 514 -39966 -59452 124 514 -39965 -59452 125 514 -39964 -59452 126 514 -39963 -59452 127 514 ...

result:

ok ok Sum L = 4851

Test #14:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

50
191 981 19
191 980 41
191 979 20
191 978 14
191 977 2
191 976 49
191 975 40
191 974 3
191 973 20
191 972 6
191 971 13
191 970 4
191 969 4
191 968 47
191 967 32
191 966 11
191 965 34
191 964 30
191 963 3
191 962 16
191 961 24
191 960 30
191 959 34
191 958 31
191 957 24
191 956 29
191 955 42
191 95...

output:

49
99 191 981 -53181 -78854 191 980 -10460 -14952 191 979 -31641 -46636 191 978 -52822 -78320 191 977 -10101 -14418 191 976 -31282 -46102 191 975 -52463 -77786 191 974 -9742 -13884 191 973 -30923 -45568 191 972 -52104 -77252 191 971 -9383 -13350 191 970 -30564 -45034 191 969 -51745 -76718 191 968 -9...

result:

ok ok Sum L = 4851

Test #15:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

50
-123 456 47
-122 457 35
-121 458 25
-120 459 35
-119 460 30
-118 461 33
-117 462 21
-116 463 31
-115 464 21
-114 465 35
-113 466 20
-112 467 17
-111 468 25
-110 469 3
-109 470 29
-108 471 35
-107 472 4
-106 473 44
-105 474 4
-104 475 28
-103 476 49
-102 477 9
-101 478 39
-100 479 9
-99 480 21
-98...

output:

50
99 -123 456 -54572 -80990 -122 457 -33390 -49306 -121 458 -12208 -17622 -120 459 -54928 -81524 -119 460 -33746 -49840 -118 461 -12564 -18156 -117 462 -55284 -82058 -116 463 -34102 -50374 -115 464 -12920 -18690 -114 465 -55640 -82592 -113 466 -34458 -50908 -112 467 -13276 -19224 -111 468 -55996 -8...

result:

ok ok Sum L = 4950

Test #16:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

50
321 -525 46
322 -526 14
323 -527 16
324 -528 38
325 -529 22
326 -530 24
327 -531 48
328 -532 5
329 -533 7
330 -534 30
331 -535 25
332 -536 2
333 -537 13
334 -538 1
335 -539 33
336 -540 8
337 -541 9
338 -542 2
339 -543 29
340 -544 17
341 -545 41
342 -546 39
343 -547 9
344 -548 47
345 -549 47
346 -...

output:

50
99 321 -525 63265 93628 322 -526 42085 61944 323 -527 20905 30260 324 -528 63627 94162 325 -529 42447 62478 326 -530 21267 30794 327 -531 63989 94696 328 -532 42809 63012 329 -533 21629 31328 330 -534 64351 95230 331 -535 43171 63546 332 -536 21991 31862 333 -537 811 178 334 -538 43533 64080 335 ...

result:

ok ok Sum L = 4950

Test #17:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

50
-444 -555 23
-445 -556 32
-446 -557 36
-447 -558 29
-448 -559 4
-449 -560 25
-450 -561 29
-451 -562 5
-452 -563 9
-453 -564 28
-454 -565 35
-455 -566 26
-456 -567 22
-457 -568 39
-458 -569 13
-459 -570 50
-460 -571 37
-461 -572 14
-462 -573 26
-463 -574 49
-464 -575 23
-465 -576 44
-466 -577 2
-4...

output:

50
99 -493 -604 -13298 -19758 -492 -603 -56018 -83660 -491 -602 -34836 -51976 -490 -601 -13654 -20292 -489 -600 -56374 -84194 -488 -599 -35192 -52510 -487 -598 -14010 -20826 -486 -597 -56730 -84728 -485 -596 -35548 -53044 -484 -595 -14366 -21360 -483 -594 -57086 -85262 -482 -593 -35904 -53578 -481 -...

result:

ok ok Sum L = 4950

Test #18:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

50
-142 0 48
-143 1 22
-144 2 45
-145 3 9
-146 4 36
-147 5 46
-148 6 26
-149 7 26
-150 8 9
-151 9 19
-152 10 22
-153 11 14
-154 12 8
-155 13 20
-156 14 41
-157 15 47
-158 16 22
-159 17 50
-160 18 3
-161 19 12
-162 20 15
-163 21 32
-164 22 46
-165 23 45
-166 24 3
-167 25 27
-168 26 33
-169 27 17
-170...

output:

50
99 -191 49 -48537 -72268 -190 48 -5815 -8366 -189 47 -26995 -40050 -188 46 -48175 -71734 -187 45 -5453 -7832 -186 44 -26633 -39516 -185 43 -47813 -71200 -184 42 -5091 -7298 -183 41 -26271 -38982 -182 40 -47451 -70666 -181 39 -4729 -6764 -180 38 -25909 -38448 -179 37 -47089 -70132 -178 36 -4367 -6...

result:

ok ok Sum L = 4950

Test #19:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

12
1000 1000 50
1000 -1000 50
1000 999 50
999 1000 50
999 -1000 50
-999 1000 50
1000 -999 50
-999 -1000 50
-1000 1000 50
-1000 -1000 50
-1000 -999 50
-1000 999 50

output:

50
23 -1000 1000 -35345 -50374 -1000 999 -56526 -82058 -999 1000 -35344 -50374 -1000 -999 -9138 -13172 -1000 -1000 -30319 -44856 -999 -1000 -30318 -44856 999 1000 30556 45212 1000 1000 30557 45212 1000 999 9376 13528 999 -1000 35582 50730 1000 -999 56764 82414 1000 -1000
23 -1000 1000 -34986 -49837 ...

result:

ok ok Sum L = 1150

Test #20:

score: 0
Accepted
time: 1ms
memory: 3428kb

input:

4
1000 1000 50
1000 -1000 50
-1000 1000 50
-1000 -1000 50

output:

50
7 -1000 1000 -35345 -50374 -1000 -1000 -30319 -44856 1000 1000 30557 45212 1000 -1000
7 -1000 1000 -34986 -49837 -1000 -1000 -29960 -44319 1000 1000 30916 45749 1000 -1000
7 -1000 1000 -34627 -49300 -1000 -1000 -29601 -43782 1000 1000 31275 46286 1000 -1000
7 -1000 1000 -34268 -48763 -1000 -1000 ...

result:

ok ok Sum L = 350

Extra Test:

score: 0
Extra Test Passed