QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#322250#5012. Water FlowluanmengleiAC ✓1ms3904kbC++172.9kb2024-02-06 16:51:482024-02-06 16:51:48

Judging History

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

  • [2024-02-06 16:51:48]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3904kb
  • [2024-02-06 16:51:48]
  • 提交

answer

#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>
#pragma comment(linker, "/STACK:836777216")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

ll xs,ys,xf,yf;
ll corner, cross, line, tshape;

void NO() {
  printf("No\n");
}

void YES() {
  printf("Yes\n");
}

ll CornerToLine(ll line) {
  return line / 2 * 4 + (line % 2 ? 3 : 0);
}

int main(void) {
  scanf("%lld%lld", &xs, &ys);
  scanf("%lld%lld", &xf, &yf);
  scanf("%lld%lld%lld%lld", &corner, &cross, &line, &tshape);

  cross-= 2;
  tshape += cross;

  ll dx = abs(xs - xf);
  ll dy = abs(ys - yf);

  if (dy > dx) {
    swap(dx, dy);
  }

  //special cases
  if (dy == 0) {
    if (dx == 1) {
      YES();
      return 0;
    }
    dx--;

    ll needed = (line + tshape < dx ? dx - (line + tshape) : 0);

    if (needed) {
      ll corner_needed = CornerToLine(needed);

      if (corner_needed > corner) {
        NO();
        return 0;
      }
    }

    YES();
    return 0;
  }

  if (corner + tshape < 1) {
    NO();
    return 0;
  }

  if (!corner) {
    corner++;
    tshape--;
  }

  corner--;

  line += tshape;

  dx--;
  dy--;

  if (dx + dy <= line) {
    YES();
    return 0;
  }

  ll corners_rep = min(dy, corner / 2);
  dx -= corners_rep;
  dy -= corners_rep;
  corner -= corners_rep * 2;

  ll line_y = min(dy, line);
  dy -= line_y;
  line -= line_y;

  ll line_x = min(dx, line);
  dx -= line_x;
  line -= line_x;

  ll corners_needed = 0;

  if (!dy) {
    if (dx % 2) {
      dx--;
      corners_needed++;
    }
  }
  corners_needed += CornerToLine(dx) + CornerToLine(dy);
  if (corners_needed > corner) {
    NO();
    return 0;
  }
  YES();
  return 0;
}







详细

Test #1:

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

input:

8 7
14 3
3 2 6 0

output:

Yes

result:

ok answer is YES

Test #2:

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

input:

8 7
14 3
1 2 7 0

output:

No

result:

ok answer is NO

Test #3:

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

input:

1 1
5 2
6 2 0 0

output:

Yes

result:

ok answer is YES

Test #4:

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

input:

1 1
5 3
7 2 0 0

output:

Yes

result:

ok answer is YES

Test #5:

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

input:

1 1
5 3
6 2 0 0

output:

No

result:

ok answer is NO

Test #6:

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

input:

1 1
5 3
6 2 1 0

output:

Yes

result:

ok answer is YES

Test #7:

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

input:

423 342343
5345435 54543
0 2 10000000000 0

output:

No

result:

ok answer is NO

Test #8:

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

input:

423 342343
5345435 54543
0 2 10000000000 1

output:

Yes

result:

ok answer is YES

Test #9:

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

input:

423 342343
5345435 54543
0 3 10000000000 0

output:

Yes

result:

ok answer is YES

Test #10:

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

input:

0 0
0 1
0 2 0 0

output:

Yes

result:

ok answer is YES

Test #11:

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

input:

0 0
0 3
0 2 0 2

output:

Yes

result:

ok answer is YES

Test #12:

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

input:

0 0
0 3
2 2 0 0

output:

No

result:

ok answer is NO

Test #13:

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

input:

0 0
1573373051 4884179858
7775537182 269558190 554586218 172266860

output:

Yes

result:

ok answer is YES

Test #14:

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

input:

0 0
4439409947 576867199
6926043260 138955040 240034514 597398764

output:

No

result:

ok answer is NO

Test #15:

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

input:

0 0
2028526924 3268557337
2640088088 1309243081 637174403 710578690

output:

Yes

result:

ok answer is YES

Test #16:

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

input:

0 0
887542910 4751144678
2023674351 1127607766 2190518052 421181685

output:

No

result:

ok answer is NO

Test #17:

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

input:

0 0
654669977 2433832919
2791331877 791737386 51429981 194999614

output:

No

result:

ok answer is NO

Test #18:

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

input:

0 0
3312785862 3923522159
3096111052 457966633 817900422 2864329915

output:

Yes

result:

ok answer is YES

Test #19:

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

input:

0 0
1181812648 1615119278
14633898 1463851575 554511051 763935402

output:

No

result:

ok answer is NO

Test #20:

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

input:

0 0
4978937615 1107819419
7909205910 446789244 475834226 101711191

output:

Yes

result:

ok answer is YES

Test #21:

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

input:

0 0
4537055602 899506759
6196409117 1391908876 36696688 10245480

output:

No

result:

ok answer is NO

Test #22:

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

input:

0 0
1405070688 3571996990
5570054347 570090621 127500678 89378518

output:

No

result:

ok answer is NO

Test #23:

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

input:

0 0
4264198555 4063664239
5900563401 321365468 1978427376 127506550

output:

Yes

result:

ok answer is YES

Test #24:

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

input:

0 0
2831223332 2655351479
354555045 3480705303 757837579 893476884

output:

No

result:

ok answer is NO

Test #25:

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

input:

0 0
610341328 3148941790
766818334 2045936890 566270162 380257733

output:

Yes

result:

ok answer is YES

Test #26:

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

input:

0 0
589266315 1810638031
389411228 1053612648 587746213 369134258

output:

Yes

result:

ok answer is YES

Test #27:

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

input:

0 0
3145383272 1302328279
1057040655 842195909 939696472 1608778515

output:

No

result:

ok answer is NO

Test #28:

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

input:

0 0
0 1573373051
2505425948 92636097 92445662 135578319

output:

Yes

result:

ok answer is YES

Test #29:

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

input:

0 0
0 4439409947
7174279675 135521998 108469770 608278342

output:

No

result:

ok answer is NO

Test #30:

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

input:

0 0
0 2028526924
2444648547 291412707 318011309 196778635

output:

No

result:

ok answer is NO

Test #31:

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

input:

0 0
0 887542910
1019823003 98925952 123553251 155152207

output:

Yes

result:

ok answer is YES

Test #32:

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

input:

0 0
0 654669977
1059745656 42592898 36160551 46043701

output:

Yes

result:

ok answer is YES

Test #33:

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

input:

0 0
0 3312785862
5544071552 91058426 213644141 236047520

output:

Yes

result:

ok answer is YES

Test #34:

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

input:

0 0
0 1181812648
1264968434 21140564 182365299 345822569

output:

No

result:

ok answer is NO

Test #35:

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

input:

0 0
0 4978937615
7015994570 468906111 781284518 220749702

output:

No

result:

ok answer is NO

Test #36:

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

input:

0 0
0 4537055602
2834863936 588126633 1398539938 1132957064

output:

Yes

result:

ok answer is YES

Test #37:

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

input:

0 0
0 1405070688
52785283 82479248 478980856 817217944

output:

Yes

result:

ok answer is YES

Test #38:

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

input:

0 0
0 4264198555
7476555879 421123955 55160926 49635735

output:

No

result:

ok answer is NO

Test #39:

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

input:

0 0
0 2831223332
2856053335 1125192180 141938622 136065863

output:

No

result:

ok answer is NO

Test #40:

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

input:

0 0
0 610341328
233781667 85914651 196508577 211027268

output:

Yes

result:

ok answer is YES

Test #41:

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

input:

0 0
0 589266315
53484776 260101125 169575771 132847032

output:

Yes

result:

ok answer is YES

Test #42:

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

input:

0 0
0 3145383272
5104294016 545963402 40864242 6408621

output:

Yes

result:

ok answer is YES

Test #43:

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

input:

0 0
2793359654 2575148304
5586719307 2 0 0

output:

Yes

result:

ok answer is YES

Test #44:

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

input:

0 0
2509607080 4661688205
9323376407 2 0 0

output:

No

result:

ok answer is NO

Test #45:

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

input:

0 0
1015053526 1740108096
3480216190 2 0 0

output:

No

result:

ok answer is NO

Test #46:

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

input:

0 0
2812581234 3637658089
7275316176 2 0 0

output:

Yes

result:

ok answer is YES

Test #47:

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

input:

0 0
1528936769 726178980
3057873536 2 0 0

output:

Yes

result:

ok answer is YES

Test #48:

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

input:

0 0
2335384395 3823818771
7647637540 2 0 0

output:

No

result:

ok answer is NO

Test #49:

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

input:

0 0
1831610831 910338762
3663221659 2 0 0

output:

No

result:

ok answer is NO

Test #50:

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

input:

0 0
2647268349 2809970663
5619941325 2 0 0

output:

Yes

result:

ok answer is YES

Test #51:

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

input:

0 0
334614075 4085490456
8170980910 2 0 0

output:

Yes

result:

ok answer is YES

Test #52:

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

input:

0 0
1150961400 1174130236
2348260470 2 0 0

output:

No

result:

ok answer is NO

Test #53:

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

input:

0 0
0 1573373051
3146746099 2 0 0

output:

No

result:

ok answer is NO

Test #54:

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

input:

0 0
0 4439409947
8878819892 2 0 0

output:

Yes

result:

ok answer is YES

Test #55:

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

input:

0 0
0 2028526924
4057053847 2 0 0

output:

Yes

result:

ok answer is YES

Test #56:

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

input:

0 0
0 887542910
1775085818 2 0 0

output:

No

result:

ok answer is NO

Test #57:

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

input:

0 0
0 654669977
1309339952 2 0 0

output:

Yes

result:

ok answer is YES

Test #58:

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

input:

0 0
0 3312785862
6625571722 2 0 0

output:

No

result:

ok answer is NO

Test #59:

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

input:

0 0
0 1181812648
2363625294 2 0 0

output:

No

result:

ok answer is NO

Test #60:

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

input:

0 0
0 4978937615
9957875228 2 0 0

output:

Yes

result:

ok answer is YES

Test #61:

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

input:

0 0
0 4537055602
9074111202 2 0 0

output:

No

result:

ok answer is NO

Test #62:

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

input:

0 0
0 1405070688
2810141375 2 0 0

output:

Yes

result:

ok answer is YES