# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1050029 |
2024-08-09T06:56:40 Z |
ksun69(#11101) |
Hamburg Steak (JOI20_hamburg) |
C++17 |
|
484 ms |
89076 KB |
#include <bits/stdc++.h>
using namespace std;
namespace std {
template<class Fun>
class y_combinator_result {
Fun fun_;
public:
template<class T>
explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}
template<class ...Args>
decltype(auto) operator()(Args &&...args) {
return fun_(std::ref(*this), std::forward<Args>(args)...);
}
};
template<class Fun>
decltype(auto) y_combinator(Fun &&fun) {
return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
} // namespace std
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int N, K;
cin >> N >> K;
vector<vector<int> > S(N, vector<int>(4));
for(int i = 0; i < N; i++){
for(int j = 0; j < 4; j++){
cin >> S[i][j];
}
}
// L D R U
vector<pair<int,int> > bad = {{-1, -1}};
auto sol = y_combinator([&](auto self, vector<vector<int>> s, int k) -> vector<pair<int,int> > {
if(s.size() == 0) return vector<pair<int,int> >(k, {0, 0});
if(k == 0) return bad;
vector<int> bounds {int(-1e9), int(-1e9), int(1e9), int(1e9)};
for(int i = 0; i < (int)s.size(); i++){
bounds[0] = max(bounds[0], s[i][0]);
bounds[1] = max(bounds[1], s[i][1]);
bounds[2] = min(bounds[2], s[i][2]);
bounds[3] = min(bounds[3], s[i][3]);
}
for(int x : {bounds[0], bounds[2]}){
for(int y : {bounds[1], bounds[3]}){
vector<vector<int> > nxt;
for(int i = 0; i < (int)s.size(); i++){
if(!(s[i][0] <= x && s[i][2] >= x && s[i][1] <= y && s[i][3] >= y)) nxt.push_back(s[i]);
}
auto res = self(nxt, k-1);
if(res != bad) {
res.push_back({x, y});
return res;
}
}
}
return bad;
})(S, K);
if(sol != bad){
for(int i = 0; i < K; i++){
cout << sol[i].first << ' ' << sol[i].second << '\n';
}
} else {
assert(false);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
1056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
5 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
1116 KB |
Output is correct |
11 |
Correct |
2 ms |
892 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
14 ms |
1500 KB |
Output is correct |
9 |
Correct |
3 ms |
1116 KB |
Output is correct |
10 |
Correct |
8 ms |
1116 KB |
Output is correct |
11 |
Correct |
15 ms |
1624 KB |
Output is correct |
12 |
Correct |
4 ms |
1156 KB |
Output is correct |
13 |
Correct |
1 ms |
848 KB |
Output is correct |
14 |
Runtime error |
12 ms |
2400 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
60 ms |
22356 KB |
Output is correct |
6 |
Correct |
67 ms |
22356 KB |
Output is correct |
7 |
Correct |
58 ms |
22164 KB |
Output is correct |
8 |
Correct |
83 ms |
22156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
640 KB |
Output is correct |
4 |
Correct |
1 ms |
1056 KB |
Output is correct |
5 |
Correct |
78 ms |
41144 KB |
Output is correct |
6 |
Correct |
91 ms |
54528 KB |
Output is correct |
7 |
Correct |
67 ms |
39684 KB |
Output is correct |
8 |
Correct |
150 ms |
62500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
5 ms |
1116 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
4 ms |
1116 KB |
Output is correct |
11 |
Correct |
2 ms |
892 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
75 ms |
46600 KB |
Output is correct |
14 |
Correct |
89 ms |
46340 KB |
Output is correct |
15 |
Correct |
79 ms |
48932 KB |
Output is correct |
16 |
Correct |
77 ms |
41132 KB |
Output is correct |
17 |
Correct |
82 ms |
44288 KB |
Output is correct |
18 |
Correct |
68 ms |
37896 KB |
Output is correct |
19 |
Correct |
74 ms |
46264 KB |
Output is correct |
20 |
Correct |
484 ms |
87856 KB |
Output is correct |
21 |
Correct |
89 ms |
55584 KB |
Output is correct |
22 |
Correct |
187 ms |
89076 KB |
Output is correct |
23 |
Correct |
322 ms |
86448 KB |
Output is correct |
24 |
Correct |
213 ms |
80512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
860 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
14 ms |
1500 KB |
Output is correct |
9 |
Correct |
3 ms |
1116 KB |
Output is correct |
10 |
Correct |
8 ms |
1116 KB |
Output is correct |
11 |
Correct |
15 ms |
1624 KB |
Output is correct |
12 |
Correct |
4 ms |
1156 KB |
Output is correct |
13 |
Correct |
1 ms |
848 KB |
Output is correct |
14 |
Runtime error |
12 ms |
2400 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |