QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#110937 | #6563. Four Square | USP_USP_USP# | RE | 3ms | 3416kb | C++23 | 2.4kb | 2023-06-04 22:37:31 | 2023-06-04 22:37:33 |
Judging History
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();
}
Details
Tip: Click on the bar to expand more detailed information
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