이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e18;
array<int, 2> A[100005];
void subtask_1(int N) {
int mx = -INF, ix = INF, my = -INF, iy = INF;
int i, j;
for(i=0;i<N;i++) {
mx = max(mx, A[i][0]);
ix = min(ix, A[i][0]);
my = max(my, A[i][1]);
iy = min(iy, A[i][1]);
}
cout << ix << ' ' << iy << ' ' << max(mx - ix, my - iy);
}
array<int, 3> ans[3];
void subtask_2(int N) {
}
array<int, 3> B[3];
bool in(int k, int a) {
return B[a][0] <= A[k][0] && A[k][0] <= B[a][0] + B[a][2] && B[a][1] <= A[k][1] && A[k][1] <= B[a][1] + B[a][2];
}
int pw3[14];
void subtask_3(int N) {
int i, j;
pw3[0] = 1;
for(i=1;i<=N;i++) pw3[i] = pw3[i-1] * 3;
int mi = INF;
for(i=0;i<pw3[N];i++) {
vector<int> V[3];
for(j=0;j<N;j++) {
int k = (i / pw3[j]) % 3;
V[k].push_back(j);
}
for(j=0;j<3;j++) {
int mx = -INF, ix = INF, my = -INF, iy = INF;
for(int k : V[j]) {
mx = max(mx, A[k][0]);
ix = min(ix, A[k][0]);
my = max(my, A[k][1]);
iy = min(iy, A[k][1]);
}
if(mx==-INF) B[j] = {1e9 + 2*j, 1e9 + 2*j, 1};
else B[j] = {ix, iy, max(1LL, max(mx - ix, my - iy))};
}
bool isPos = true;
for(j=0;j<3;j++) {
set<int> S;
for(int k = 0; k < N; k++) S.insert(k);
for(int k : V[j]) S.erase(k);
for(int k : S) {
if(in(k, j)) isPos = false;
}
}
int val = 0;
for(j=0;j<3;j++) val = max(val, B[j][2]);
if(mi > val && isPos) {
mi = val;
ans[0] = B[0], ans[1] = B[1], ans[2] = B[2];
}
}
cout << ans[0][0] << ' ' << ans[0][1] << ' ' << ans[0][2] << '\n';
cout << ans[1][0] << ' ' << ans[1][1] << ' ' << ans[1][2] << '\n';
cout << ans[2][0] << ' ' << ans[2][1] << ' ' << ans[2][2] << '\n';
}
signed main() {
cin.sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N, K;
cin >> N >> K;
int i, j;
for(i=0;i<N;i++) cin >> A[i][0] >> A[i][1];
if(N==1) {
cout << A[0][0] << ' ' << A[0][1] << ' ' << 1 << '\n';
if(K>=2) cout << 1e9 + 2 << ' ' << 1e9 + 2 << ' ' << 1 << '\n';
if(K>=3) cout << 1e9 + 4 << ' ' << 1e9 + 4 << ' ' << 1 <<'\n';
return 0;
}
if(K==1) {
subtask_1(N);
}
if(K==2) {
subtask_2(N);
}
if(K==3) {
subtask_3(N);
}
}
컴파일 시 표준 에러 (stderr) 메시지
izvanzemaljci.cpp: In function 'void subtask_1(long long int)':
izvanzemaljci.cpp:8:12: warning: unused variable 'j' [-Wunused-variable]
8 | int i, j;
| ^
izvanzemaljci.cpp: In function 'void subtask_3(long long int)':
izvanzemaljci.cpp:45:38: warning: narrowing conversion of '(1.0e+9 + (double)(2 * j))' from 'double' to 'long long int' [-Wnarrowing]
45 | if(mx==-INF) B[j] = {1e9 + 2*j, 1e9 + 2*j, 1};
| ~~~~^~~~~
izvanzemaljci.cpp:45:49: warning: narrowing conversion of '(1.0e+9 + (double)(2 * j))' from 'double' to 'long long int' [-Wnarrowing]
45 | if(mx==-INF) B[j] = {1e9 + 2*j, 1e9 + 2*j, 1};
| ~~~~^~~~~
izvanzemaljci.cpp: In function 'int main()':
izvanzemaljci.cpp:74:12: warning: unused variable 'j' [-Wunused-variable]
74 | int i, j;
| ^
# | 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... |