이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#define int ll
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll NMAX = 1000001;
const ll INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
struct rect {
int x1, y1, x2, y2;
} q[NMAX];
rect buckets[11];
int last[NMAX];
rect combine(rect a, rect b) {
rect sol = {max(a.x1, b.x1), max(a.y1, b.y1), min(a.x2, b.x2), min(a.y2, b.y2)};
return sol;
}
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
srand(time(0));
int n, i, k;
cin >> n >> k;
for(i = 1; i <= n; i++) {
cin >> q[i].x1 >> q[i].y1 >> q[i].x2 >> q[i].y2;
}
vector <int> qq;
for(i = 1; i <= n; i++) {
qq.push_back(i);
}
while(1) {
for(int j = 1; j <= k; j++) {
buckets[j] = {0, 0, INF, INF};
}
int cnt = 0;
for(int i = 0; i < qq.size(); i++){
int acum = qq[i];
int oke = 0;
int care = 0;
for(int j = 1; j <= k; j++) {
rect inters = combine(q[acum], buckets[j]);
if(inters.x1 <= inters.x2 && inters.y1 <= inters.y2) {
care = j;
oke++;
}
}
if(oke){
cnt++;
buckets[care] = combine(buckets[care], q[acum]);
}
else{
random_shuffle(qq.begin() + i, qq.end());
break;
}
}
if(cnt == n) {
for(i = 1; i <= k; i++) {
cout << buckets[i].x1 << " " << buckets[i].y1 << "\n";
}
return 0;
}
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
hamburg.cpp: In function 'int main()':
hamburg.cpp:54:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i = 0; i < qq.size(); i++){
| ~~^~~~~~~~~~~
# | 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... |