QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#110937#6563. Four SquareUSP_USP_USP#RE 3ms3416kbC++232.4kb2023-06-04 22:37:312023-06-04 22:37:33

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-04 22:37:33]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:3416kb
  • [2023-06-04 22:37:31]
  • 提交

answer

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

using ll = long long;
// #define int ll
#define all(v) (v).begin(), (v).end()
#define pb push_back

void dbg_out() { cerr << endl; }
template<typename H, typename... T> 
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }

int raiz (int x) {
    int y = max<int> (0, sqrt (x) - 2);
    while (y * y < x) y++;
    return y;
}

void solve() {
    int area = 0;
    vector<pair<int, int>> a (4);
    for (auto &[x, y] : a) cin >> x >> y, area += x * y;

    int l = raiz (area);
    if (l * l != area) {
        cout << "0\n";
        return;
    }

    // dbg (l);

    vector<int> perm (4);
    iota (all (perm), 0);

    do {
        // for (auto u : perm) cout << u << " ";
        // cout << "\n";
        // dbg ("A");
        for (int mask = 0; mask < 8; mask++) {
            vector tab (l, vector<int> (l));
            bool ok = true;
            int k = 0;
            for (int i = 0; i < l && ok; i++) {
                for (int j = 0; j < l && ok; j++) if (!tab[i][j]) {
                    // se nao pintamos
                    int u = perm[k];
                    auto [x, y] = a[perm[k]];
                    if (mask & (1 << k)) swap (x, y);
                    k++;
                    // vamos colocar o quadrado x, y
                    if (i + x > l || i + y > l) {
                        ok = false;
                        break;
                    }
                    // dbg (i, j, x, y);
                    for (int ii = i; ii < i + x; ii++)
                        for (int jj = j; jj < j + y; jj++) {
                            if (tab[ii][jj]) ok = false;
                            else tab[ii][jj] = 1;
                        }
                    j += y - 1;
                }
            }
            if (ok) {
                // for (int i = 0; i < l; i++)
                //     for (int j = 0; j < l; j++) cout << tab[i][j] << " \n"[j == l - 1];
                // for (auto u : perm) cout << u << " ";
                // cout << "\n";
                cout << "1\n";
                return;
            }
        }
    } while (next_permutation (all (perm))); 
    cout << "0\n";
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 3396kb

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Dangerous Syscalls

input:

2 8
2 8
2 8
2 8

output:


result: