QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#178515#2160. CardiologyAlleks_BAC ✓144ms3740kbC++141.1kb2023-09-14 02:04:522023-09-14 02:04:52

Judging History

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

  • [2023-09-14 02:04:52]
  • 评测
  • 测评结果:AC
  • 用时:144ms
  • 内存:3740kb
  • [2023-09-14 02:04:52]
  • 提交

answer

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

long long l, c;

long long dist(long long x1, long long y1, long long x2, long long y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}

int main() {
  cin >> l >> c;
  long long d_min = (1 << 30), p_min = -1, pos = -1, ok_ans = -1;
  for (long long p = 1; p <= c; p++) {
    long long ok = 0;
    long long ant_le = -1, ant_ri = -1, le = 0, ri = l * c - 1;
    for (long long i = 0; !ok && i < STEPS; i++) {
      le = 1LL * (p - 1) * l + le / c;
      ri = 1LL * (p - 1) * l + ri / c;
      if (le == ri && ant_le == le && ant_ri == ri)
        ok = i;
      ant_le = le;
      ant_ri = ri;
    }
    if (ok) {
      long long d = min(min(dist(le / c, le % c, (l - 1) / 2, (c - 1) / 2), dist(le / c, le % c, (l - 1) / 2, c / 2)), min(dist(le / c, le % c, l / 2, (c - 1) / 2), dist(le / c, le % c, l / 2, c / 2)));
      if (d < d_min) {
        d_min = d;
        p_min = p;
        pos = le;
        ok_ans = ok;
      }
    }
  }
  cout << p_min << " " << pos / c + 1 << " " << pos % c + 1 << " " << ok_ans << "\n";
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 17ms
memory: 3656kb

input:

6666 966364

output:

473832 3269 483163 2

result:

ok single line: '473832 3269 483163 2'

Test #2:

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

input:

36 906986

output:

12598 1 453493 2

result:

ok single line: '12598 1 453493 2'

Test #3:

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

input:

704877 297616

output:

148803 352426 140980 3

result:

ok single line: '148803 352426 140980 3'

Test #4:

score: 0
Accepted
time: 21ms
memory: 3656kb

input:

1000000 1000000

output:

500000 500000 500000 2

result:

ok single line: '500000 500000 500000 2'

Test #5:

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

input:

2 2

output:

1 1 1 2

result:

ok single line: '1 1 1 2'

Test #6:

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

input:

1000000 2

output:

1 1 1 21

result:

ok single line: '1 1 1 21'

Test #7:

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

input:

2 1000000

output:

250001 1 500001 2

result:

ok single line: '250001 1 500001 2'

Test #8:

score: 0
Accepted
time: 14ms
memory: 3732kb

input:

985391 511611

output:

255806 492696 255806 3

result:

ok single line: '255806 492696 255806 3'

Test #9:

score: 0
Accepted
time: 15ms
memory: 3596kb

input:

435766 614914

output:

304739 215957 307481 2

result:

ok single line: '304739 215957 307481 2'

Test #10:

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

input:

818196 58

output:

29 401921 49 5

result:

ok single line: '29 401921 49 5'

Test #11:

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

input:

401765 19

output:

10 200883 10 6

result:

ok single line: '10 200883 10 6'

Test #12:

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

input:

95 912669

output:

456335 48 456335 2

result:

ok single line: '456335 48 456335 2'

Test #13:

score: 0
Accepted
time: 6ms
memory: 3740kb

input:

81 429950

output:

2655 1 214975 2

result:

ok single line: '2655 1 214975 2'

Test #14:

score: 0
Accepted
time: 23ms
memory: 3660kb

input:

999956 999959

output:

249991 249990 499979 3

result:

ok single line: '249991 249990 499979 3'

Test #15:

score: 0
Accepted
time: 26ms
memory: 3644kb

input:

999935 999946

output:

449976 449971 499976 3

result:

ok single line: '449976 449971 499976 3'

Test #16:

score: 0
Accepted
time: 144ms
memory: 3712kb

input:

999951 999952

output:

1 1 1 2

result:

ok single line: '1 1 1 2'

Test #17:

score: 0
Accepted
time: 6ms
memory: 3668kb

input:

106352 224337

output:

112111 53149 112993 2

result:

ok single line: '112111 53149 112993 2'

Test #18:

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

input:

651870 786333

output:

392936 325744 393775 2

result:

ok single line: '392936 325744 393775 2'

Test #19:

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

input:

838522 972888

output:

486249 419093 486853 2

result:

ok single line: '486249 419093 486853 2'