QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#111015#6563. Four SquareTobo#WA 2ms3564kbC++201.5kb2023-06-05 14:18:342023-06-05 14:18:36

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-05 14:18:36]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3564kb
  • [2023-06-05 14:18:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define N 2005

int x[4], y[4], sum;
void solve()
{
    for (int i = 0; i < 4; i++)
        cin >> x[i] >> y[i], sum += x[i] * y[i];
    int a = sqrt(sum + 0.5);
    if (a * a != sum)
    {
        cout << 0;
        return;
    }
    int tmp[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}};
    auto check = [&](int x, int y) -> bool
    {
        for (int i : tmp[x])
            if (i == y)
                return 1;
        return 0;
    };
    for (int i = 0; i < 16; i++)
    {
        for (int p = 0; p < 6; p++)
        {
            int b = 0, c = 0, d = 0, e = 0;
            for (int j = 0; j < 4; j++)
            {
                if (check(p, j))
                {
                    if (i >> j & 1)
                        b += x[j], c += y[j];
                    else
                        b += y[j], c += x[j];
                }
                else
                {
                    if (i >> j & 1)
                        d += x[j], e += y[j];
                    else
                        d += y[j], e += x[j];
                }
            }
            if (a == b && a == c && a == d && a == e)
            {
                cout << 1;
                return;
            }
        }
    }
    cout << 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3564kb

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3520kb

input:

2 8
2 8
2 8
2 8

output:

0

result:

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