QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#354814 | #6563. Four Square | kevinshan# | WA | 0ms | 3780kb | C++17 | 2.3kb | 2024-03-16 03:00:14 | 2024-03-16 03:00:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define i4 array<int, 4>
#define ff first
#define ss second
int x[4], y[4], a[4000][4000];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen("input.in", "r")) {
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
}
int cur = 0;
for (int i=0; i<4; i++) cin>>x[i]>>y[i], cur += x[i] * y[i];
int sq = sqrt(cur);
if (sq * sq != cur) return cout<<0, 0;
for (int i=0; i<16; i++)
{
vector<ii> v;
for (int j=0; j<4; j++) if (i >> j & 1) v.push_back({y[j], x[j]}); else v.push_back({x[j], y[j]});
sort(v.begin(), v.end());
do
{
bool f = 1;
vector<i4> ve;
for (auto [x, y]: v)
{
/* Find upmost line */
int xx = -1, yy = -1;
for (int i=0; i<sq; i++)
{
int curcol = 0;
for (int _=0; _<10; _++)
{
for (auto rec: ve)
{
if (rec[0] <= i && rec[2] > i && rec[1] <= curcol && rec[3] > curcol)
curcol = max(curcol, rec[3]);
}
}
if (curcol < sq)
{
xx = i;
yy = curcol;
break;
}
}
assert(xx != -1);
// cout<<"HEH: "<<xx<<" "<<yy<<"\n";
if (xx + x > sq || yy + y > sq)
{
f = 0;
break;
}
ve.push_back({xx, yy, xx+x, yy+y});
sort(ve.begin(), ve.end());
// for (auto x: ve) cout<<"BRUH: "<<x[0]<<" "<<x[1]<<" "<<x[2]<<" "<<x[3]<<"\n";
}
if (f)
{
// for (auto [x, y]: v) cout<<"HUH: "<<x<<" "<<y<<"\n";
// for (auto x: ve) cout<<"BRUH: "<<x[0]<<" "<<x[1]<<" "<<x[2]<<" "<<x[3]<<"\n";
return cout<<1, 0;
}
// break;
} while (next_permutation(v.begin(), v.end()));
}
cout<<0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3544kb
input:
3 1 3 3 2 2 3 3
output:
1
result:
wrong answer 1st lines differ - expected: '0', found: '1'