#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cassert>
#include <climits>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N = 2006;
int x[N], y[N], r[N];
vector<int> g[N];
bool col[4][N],us[N],chn[4][4],nd[4];
void dfs(int v) {
us[v] = true;
for (auto to : g[v]) {
if (us[to])continue;
dfs(to);
for (int i = 0; i < 4; i++) {
col[i][v] = col[i][v] || col[i][to];
}
}
}
int main() {
//freopen("input.txt", "r", stdin);
ios_base::sync_with_stdio(false);
int n,m,w,h;
cin >> n >> m >> w >> h;
assert(n == 5 && m == 3 && w == 16 && h == 11);
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i] >> r[i];
}
for (int hg = 0; hg < m; hg++) {
int del,k;
cin >> del >> k;
w -= del;
h -= del;
for (int i = 0; i < n; i++) {
r[i] += del;
x[i] -= del;
y[i] -= del;
}
for (int i = 0; i < n; i++) {
if (x[i] + r[i]>w)col[0][i] = true;
if (x[i] - r[i]<0)col[2][i] = true;
if (y[i] + r[i]>h)col[1][i] = true;
if (y[i] - r[i]<0)col[3][i] = true;
for (int j = 0; j < n; j++) {
if (i == j)continue;
if ((ll)((ll)(x[i] - x[j])*(ll)(x[i] - x[j]) + (ll)(y[i] - y[j])*(ll)(y[i] - y[j])) < (ll)((ll)(r[i] + r[j])*(ll)(r[i] + r[j]))) {
g[i].push_back(j);
}
}
}
for (int v = 0; v < n; v++) {
if (!us[v]) {
dfs(v);
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
chn[i][j] = chn[i][j] || (col[i][v] && col[j][v]);
}
r[v] -= del;
x[v] += del;
y[v] += del;
g[v].clear();
}
for (int i = 0; i < 4; i++) {
nd[i] = true;
for (int j = 0; j < 4; j++) {
if (i == j) continue;
nd[i] = nd[i] && !chn[i][j];
}
}
if (k == 1) {
cout << 1;
if (nd[3])cout << 2;
if (!chn[2][3] && !chn[1][0] && !chn[1][3] && !chn[0][2])cout << 3;
if (nd[2])cout << 4;
}
else if (k == 2) {
if (nd[3])cout << 1;
cout << 2;
if (nd[0])cout << 3;
if (!chn[1][2] && !chn[3][0] && !chn[1][3] && !chn[0][2])cout << 4;
}
else if (k == 3) {
if (!chn[2][3] && !chn[1][0] && !chn[1][3] && !chn[0][2])cout << 1;
if (nd[0])cout << 2;
cout << 3;
if (nd[1])cout << 4;
}
else if (k == 4) {
if (nd[2])cout << 1;
if (!chn[1][2] && !chn[3][0] && !chn[1][3] && !chn[0][2])cout << 2;
if (nd[1])cout << 3;
cout << 4;
}
cout << endl;
for (int i = 0; i < n; i++) {
us[i] = false;
for (int j = 0; j < 4; j++) {
col[j][i] = false;
}
}
for (int i = 0; i < 4; i++) {
nd[i] = false;
for (int j = 0; j < 4; j++) {
chn[i][j] = false;
}
}
w += del;
h += del;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
884 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |