# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
787389 |
2023-07-19T06:43:34 Z |
이동현(#10034) |
함박 스테이크 (JOI20_hamburg) |
C++17 |
|
3000 ms |
1420 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<vector<int>> a(n, vector<int>(4));
for(int i = 0; i < n; ++i){
cin >> a[i][0] >> a[i][1] >> a[i][2] >> a[i][3];
}
auto solve4 = [&](vector<vector<int>> a, int onex, int oney)->void{
int n = (int)a.size();
if(!n){
for(int i = 0; i < 4; ++i){
cout << onex << ' ' << oney << '\n';
}
}
auto chk = [&](vector<vector<int>> x, vector<vector<int>> pos){
for(int i = 0; i < (int)x.size(); ++i){
int ok = 0;
for(auto&j:pos){
if(j[0] >= x[i][0] && j[0] <= x[i][2] && j[1] >= x[i][1] && j[1] <= x[i][3]){
ok = 1;
break;
}
}
if(!ok) return 0;
}
return 1;
};
auto solve1 = [&](vector<vector<int>> x)->vector<int>{
int xp = 1, yp = 1;
for(int i = 0; i < (int)x.size(); ++i){
xp = max(xp, x[i][0]);
yp = max(yp, x[i][1]);
}
if(chk(x, {{xp, yp}})){
return {1, xp, yp};
}
return {0};
};
int xu = (int)2e9, xd = -1, yl = (int)2e9, yr = -1;
for(int i = 0; i < n; ++i){
xu = min(xu, a[i][2]);
xd = max(xd, a[i][0]);
yl = min(yl, a[i][3]);
yr = max(yr, a[i][1]);
}
auto solveline = [&](vector<vector<int>> x){
vector<int> rv;
sort(x.begin(), x.end(), [&](vector<int>&a, vector<int>&b){return a[1] < b[1];});
for(int i = 0; i < (int)x.size(); ++i){
if(!(int)rv.size() || rv.back() < x[i][0]){
rv.push_back(x[i][1]);
}
}
return rv;
};
if(xd <= xu){
vector<vector<int>> x(n);
for(int i = 0; i < n; ++i){
x[i] = {a[i][1], a[i][3]};
}
auto rv = solveline(x);
if((int)rv.size() <= 3){
for(int i = 0; i < 3; ++i){
cout << xd << ' ' << (i < (int)rv.size() ? rv[i] : rv.back()) << '\n';
}
cout << onex << ' ' << oney << '\n';
exit(0);
}
}
if(yr <= yl){
vector<vector<int>> x(n);
for(int i = 0; i < n; ++i){
x[i] = {a[i][0], a[i][2]};
}
auto rv = solveline(x);
if((int)rv.size() <= 3){
for(int i = 0; i < 3; ++i){
cout << (i < (int)rv.size() ? rv[i] : rv.back()) << ' ' << yl << '\n';
}
cout << onex << ' ' << oney << '\n';
exit(0);
}
}
auto solve2 = [&](vector<vector<int>> x, int px, int py, int ppx, int ppy){
vector<vector<int>> nxt;
for(auto&i:x){
if(!(px >= i[0] && px <= i[2] && py >= i[1] && py <= i[3])){
nxt.push_back(i);
}
}
auto rv = solve1(nxt);
if(rv[0] == 1){
cout << px << ' ' << py << '\n' << rv[1] << ' ' << rv[2] << '\n' << ppx << ' ' << ppy << '\n';
cout << onex << ' ' << oney << '\n';
exit(0);
}
};
auto solve3 = [&](vector<vector<int>> x, int px, int py){
vector<vector<int>> nxt;
for(auto&i:x){
if(!(px >= i[0] && px <= i[2] && py >= i[1] && py <= i[3])){
nxt.push_back(i);
}
}
int xu = (int)2e9, yl = (int)2e9, yr = -1;
for(int i = 0; i < (int)nxt.size(); ++i){
xu = min(xu, nxt[i][2]);
yl = min(yl, nxt[i][3]);
yr = max(yr, nxt[i][1]);
}
solve2(nxt, xu, yl, px, py);
solve2(nxt, xu, yr, px, py);
};
solve3(a, xu, yl);
solve3(a, xu, yr);
solve3(a, xd, yl);
solve3(a, xd, yr);
};
int x1 = (int)2e9;
for(int i = 0; i < n; ++i){
x1 = min(x1, a[i][2]);
}
for(int i = 0; i < n; ++i){
vector<vector<int>> nxt;
auto sol = [&](int px, int py){
vector<vector<int>> nxt;
for(auto&i:a){
if(!(px >= i[0] && px <= i[2] && py >= i[1] && py <= i[3])){
nxt.push_back(i);
}
}
solve4(nxt, px, py);
};
sol(x1, a[i][1]);
sol(x1, a[i][3]);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
144 ms |
932 KB |
Output is correct |
2 |
Correct |
2 ms |
852 KB |
Output is correct |
3 |
Correct |
72 ms |
992 KB |
Output is correct |
4 |
Correct |
1 ms |
596 KB |
Output is correct |
5 |
Correct |
129 ms |
1068 KB |
Output is correct |
6 |
Correct |
83 ms |
996 KB |
Output is correct |
7 |
Correct |
2723 ms |
1420 KB |
Output is correct |
8 |
Correct |
65 ms |
1148 KB |
Output is correct |
9 |
Correct |
123 ms |
1108 KB |
Output is correct |
10 |
Correct |
78 ms |
1108 KB |
Output is correct |
11 |
Correct |
199 ms |
1224 KB |
Output is correct |
12 |
Correct |
63 ms |
980 KB |
Output is correct |
13 |
Correct |
140 ms |
1232 KB |
Output is correct |
14 |
Correct |
1068 ms |
1316 KB |
Output is correct |
15 |
Correct |
794 ms |
1264 KB |
Output is correct |
16 |
Correct |
262 ms |
1224 KB |
Output is correct |
17 |
Correct |
1452 ms |
1244 KB |
Output is correct |
18 |
Correct |
128 ms |
1236 KB |
Output is correct |
19 |
Correct |
849 ms |
1256 KB |
Output is correct |
20 |
Correct |
2783 ms |
1332 KB |
Output is correct |
21 |
Correct |
2375 ms |
1336 KB |
Output is correct |
22 |
Correct |
304 ms |
1360 KB |
Output is correct |
23 |
Correct |
245 ms |
1300 KB |
Output is correct |
24 |
Correct |
616 ms |
1292 KB |
Output is correct |
25 |
Correct |
847 ms |
1388 KB |
Output is correct |
26 |
Correct |
563 ms |
1364 KB |
Output is correct |
27 |
Correct |
73 ms |
1260 KB |
Output is correct |
28 |
Correct |
163 ms |
1152 KB |
Output is correct |
29 |
Correct |
789 ms |
1148 KB |
Output is correct |
30 |
Correct |
602 ms |
1336 KB |
Output is correct |
31 |
Correct |
1255 ms |
1372 KB |
Output is correct |
32 |
Correct |
31 ms |
1072 KB |
Output is correct |
33 |
Correct |
147 ms |
1196 KB |
Output is correct |
34 |
Correct |
126 ms |
1160 KB |
Output is correct |
35 |
Correct |
443 ms |
1268 KB |
Output is correct |
36 |
Correct |
579 ms |
1212 KB |
Output is correct |
37 |
Execution timed out |
3070 ms |
1284 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
144 ms |
932 KB |
Output is correct |
2 |
Correct |
2 ms |
852 KB |
Output is correct |
3 |
Correct |
72 ms |
992 KB |
Output is correct |
4 |
Correct |
1 ms |
596 KB |
Output is correct |
5 |
Correct |
129 ms |
1068 KB |
Output is correct |
6 |
Correct |
83 ms |
996 KB |
Output is correct |
7 |
Correct |
2723 ms |
1420 KB |
Output is correct |
8 |
Correct |
65 ms |
1148 KB |
Output is correct |
9 |
Correct |
123 ms |
1108 KB |
Output is correct |
10 |
Correct |
78 ms |
1108 KB |
Output is correct |
11 |
Correct |
199 ms |
1224 KB |
Output is correct |
12 |
Correct |
63 ms |
980 KB |
Output is correct |
13 |
Correct |
140 ms |
1232 KB |
Output is correct |
14 |
Correct |
1068 ms |
1316 KB |
Output is correct |
15 |
Correct |
794 ms |
1264 KB |
Output is correct |
16 |
Correct |
262 ms |
1224 KB |
Output is correct |
17 |
Correct |
1452 ms |
1244 KB |
Output is correct |
18 |
Correct |
128 ms |
1236 KB |
Output is correct |
19 |
Correct |
849 ms |
1256 KB |
Output is correct |
20 |
Correct |
2783 ms |
1332 KB |
Output is correct |
21 |
Correct |
2375 ms |
1336 KB |
Output is correct |
22 |
Correct |
304 ms |
1360 KB |
Output is correct |
23 |
Correct |
245 ms |
1300 KB |
Output is correct |
24 |
Correct |
616 ms |
1292 KB |
Output is correct |
25 |
Correct |
847 ms |
1388 KB |
Output is correct |
26 |
Correct |
563 ms |
1364 KB |
Output is correct |
27 |
Correct |
73 ms |
1260 KB |
Output is correct |
28 |
Correct |
163 ms |
1152 KB |
Output is correct |
29 |
Correct |
789 ms |
1148 KB |
Output is correct |
30 |
Correct |
602 ms |
1336 KB |
Output is correct |
31 |
Correct |
1255 ms |
1372 KB |
Output is correct |
32 |
Correct |
31 ms |
1072 KB |
Output is correct |
33 |
Correct |
147 ms |
1196 KB |
Output is correct |
34 |
Correct |
126 ms |
1160 KB |
Output is correct |
35 |
Correct |
443 ms |
1268 KB |
Output is correct |
36 |
Correct |
579 ms |
1212 KB |
Output is correct |
37 |
Execution timed out |
3070 ms |
1284 KB |
Time limit exceeded |
38 |
Halted |
0 ms |
0 KB |
- |