# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
68945 |
2018-08-19T10:42:54 Z |
Abelyan |
Park (BOI16_park) |
C++17 |
|
2500 ms |
820 KB |
#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;
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 ((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;
}
Compilation message
park.cpp: In function 'int main()':
park.cpp:64:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
chn[i][j] = chn[i][j] || col[i][v] && col[j][v];
~~~~~~~~~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
504 KB |
Output is correct |
2 |
Correct |
21 ms |
616 KB |
Output is correct |
3 |
Incorrect |
19 ms |
616 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2551 ms |
820 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
504 KB |
Output is correct |
2 |
Correct |
21 ms |
616 KB |
Output is correct |
3 |
Incorrect |
19 ms |
616 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |