이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int n,k,l[200001],d[200001],r[200001],u[200001];
vector <pair <int, int>> res;
vector <int> v;
vector <int> f(vector <int> v, int x, int y){
vector <int> res;
for (int i:v)
if (l[i]>x||r[i]<x||d[i]>y||u[i]<y)
res.push_back(i);
return res;
}
bool solve(vector <int> v, int k){
if (v.empty()){
while (k--)
res.push_back({1,1});
return true;
}
if (!k)
return false;
int mn=INF,mn2=INF,mx2=0;
for (int i:v){
mn=min(mn,r[i]);
mn2=min(mn2,u[i]);
mx2=max(mx2,d[i]);
}
if (solve(f(v,mn,mn2),k-1)){
res.push_back({mn,mn2});
return true;
}
if (solve(f(v,mn,mx2),k-1)){
res.push_back({mn,mx2});
return true;
}
return false;
}
int main(){
ios_base::sync_with_stdio(NULL);cin.tie(nullptr);
cin >> n >> k;
for (int i=0;i<n;i++){
cin >> l[i] >> d[i] >> r[i] >> u[i];
v.push_back(i);
}
bool tmp=solve(v,k);
for (auto [x,y]:res)
cout << x << ' ' << y << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
hamburg.cpp: In function 'int main()':
hamburg.cpp:45:10: warning: unused variable 'tmp' [-Wunused-variable]
45 | bool tmp=solve(v,k);
| ^~~
# | 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... |