QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#758744#9750. 拼图fstqwq#WA 35ms3684kbC++201.4kb2024-11-17 19:32:592024-11-17 19:33:00

Judging History

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

  • [2024-11-17 19:33:00]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:3684kb
  • [2024-11-17 19:32:59]
  • 提交

answer

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

void work() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A < 4) cout << "0\n";
    else {
        int ans = 4;
        for (int i = 2; i <= 10; i++) {
            for (int j = 2; j <= 10; j++) {
                int a = 4;
                int b = (i - 3 + j - 3) + 2;
                int c = (i - 3 + j - 3) + 2;
                int d = (i - 2) * (j - 2);
                assert (a + b + c + d == i * j);
                if (a <= A && b <= B && c <= C && d <= D) {
                    ans = max(ans, i * j);
                } else break;
            }
        }
        for (int ij = 10; ; ij++) {
            int i = 2, j = ij - i;
            int a = 4;
            int b = (i - 3 + j - 3) + 2;
            int c = (i - 3 + j - 3) + 2;
            int d = (i - 2) * (j - 2);
            assert (a + b + c + d == i * j);
            if (a <= A && b <= B && c <= C && d <= D) {
                int l = 2, r = ij / 2;
                while (l < r) {
                    int mid = (l + r + 1) / 2;
                    if (mid * (ij - mid) <= D) l = mid;
                    else r = mid - 1;
                }
                ans = max(ans, l * (ij - l));
            } else break;
        }
        cout << ans << '\n';
    }
}

int main() {
    int T; cin >> T;
    while (T--) work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4 0 0 0
4 4 4 4

output:

4
16

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

10000
0 0 0 0
0 0 0 1
0 0 0 2
0 0 0 3
0 0 0 4
0 0 0 5
0 0 0 6
0 0 0 7
0 0 0 8
0 0 0 9
0 0 1 0
0 0 1 1
0 0 1 2
0 0 1 3
0 0 1 4
0 0 1 5
0 0 1 6
0 0 1 7
0 0 1 8
0 0 1 9
0 0 2 0
0 0 2 1
0 0 2 2
0 0 2 3
0 0 2 4
0 0 2 5
0 0 2 6
0 0 2 7
0 0 2 8
0 0 2 9
0 0 3 0
0 0 3 1
0 0 3 2
0 0 3 3
0 0 3 4
0 0 3 5
0 0 3 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 10000 lines

Test #3:

score: -100
Wrong Answer
time: 35ms
memory: 3684kb

input:

10000
931 537 776 551
811 819 334 584
895 420 468 352
954 224 103 732
643 617 385 978
608 310 256 303
561 212 871 741
324 192 179 44
949 54 897 852
388 181 293 91
265 511 49 91
640 354 190 947
886 688 330 526
708 353 725 669
47 997 339 760
417 414 873 495
902 342 778 406
402 529 950 616
73 267 114 7...

output:

1078
672
844
732
978
516
741
362
841
366
102
946
664
710
760
832
688
1062
736
1156
873
966
795
1726
1000
1716
212
606
511
532
763
1624
878
935
918
507
49
392
81
496
1074
466
1166
704
299
652
990
1586
754
490
945
612
1340
534
748
1090
1220
1020
402
1864
320
654
778
0
324
750
990
621
452
342
1326
726
...

result:

wrong answer 1st lines differ - expected: '1614', found: '1078'