이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll INF = 1e18;
struct rec{
ll l,r,d,u;
rec(ll l1= 0,ll r1 = 0,ll d1 = 0,ll u1 = 0):l(l1),r(r1),d(d1),u(u1){}
};
namespace SCC{
}
vector <rec> A;
ll n,k;
vector <pll> ans;
bool done = 0;
vector <rec> del(vector <rec> a,pll y){
vector <rec> res;
for (auto x:a){
if (x.l <= y.fi && x.r >= y.fi &&
x.d <= y.se && x.u >= y.se){}
else res.emplace_back(x);
}
return res;
}
void brute(vector <rec> cur,vector <pll> c){
if (done)return;
// for (auto x:cur)cout<<x.l<<' '<<x.r<<' '<<x.d<<' '<<x.u<<' ';
// cout<<sz(c)<<'\n';
if (sz(c)==k||cur.empty()){
while (sz(c) < k){c.push_back(MP(0,0));}
if (cur.empty()){
// for (ll i = 0;i < k;i ++)cout<<c[i].fi<<' '<<c[i].se<<'\n';
done = 1;
}
return;
}
ll L=0,R=INF,D=0,U=INF;
for (auto x:cur){
L = max(x.l,L);
R = min(x.r,R);
D = max(x.d,D);
U = min(x.u,U);
}
{
auto tmp = MP(L,D);
c.push_back(tmp);
brute(del(cur,tmp),c);
c.pop_back();
}
{
auto tmp = MP(L,U);
c.push_back(tmp);
brute(del(cur,tmp),c);
c.pop_back();
}
{
auto tmp = MP(R,D);
c.push_back(tmp);
brute(del(cur,tmp),c);
c.pop_back();
}
{
auto tmp = MP(R,U);
c.push_back(tmp);
brute(del(cur,tmp),c);
c.pop_back();
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(nullptr);
cin>>n>>k;
A.resize(n);
for (auto &x:A)cin>>x.l>>x.d>>x.r>>x.u;
brute(A,ans);
if (done)return 0;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |