QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#238997 | #6563. Four Square | Fyind# | WA | 0ms | 3824kb | C++17 | 1.6kb | 2023-11-04 18:03:06 | 2023-11-04 18:03:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 5e5 + 5;
int n, m;
pii match(int x,int y, pii s) {
vector<pii> ret;
if (s.first == x && s.second < y) return {x, y-s.second};
if (s.first == y && s.second < x) return {x - s.second, y};
return {0,0};
}
bool solve(int x,int y, vector<pii> A) {
if (x <= 0 || y <= 0) return false;
if (sz(A) == 1) {
pii s = A[0];
return s.first == x && s.second == y || s.second == x && s.first == y;
}
for (int k = 0;k < sz(A); ++k) {
pii t = match(x, y, A[k]);
if (!t.first) continue;
vector<pii> rest;
for (int i = 0;i < sz(A); ++i) if (i != k) rest.push_back(A[i]);
if (solve(t.first, t.second, rest)) return true;
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
vector<pii> sq;
vector<int> val;
set<pii> s;
for (int i = 1;i <= 4; ++i) {
int x,y; cin >> x >> y;
sq.push_back({x,y});
s.insert({x,y});
val.push_back(x); val.push_back(y);
}
if (sz(s) == 1 && s.begin()->first == s.begin()->second) {
cout << 1 << '\n';
return 0;
}
sort(val.begin(),val.end());
val.erase(unique(val.begin(),val.end()),val.end());
for (auto x : val) {
if (solve(x,x,sq)) {
cout << "1" << '\n';
return 0;
}
}
cout << '0' << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
input:
1 1 1 1 1 1 1 1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
3 1 3 3 2 2 3 3
output:
0
result:
ok single line: '0'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3824kb
input:
2 8 2 8 2 8 2 8
output:
0
result:
wrong answer 1st lines differ - expected: '1', found: '0'