Submission #68937

# Submission time Handle Problem Language Result Execution time Memory
68937 2018-08-19T10:21:21 Z Abelyan Park (BOI16_park) C++17
0 / 100
2500 ms 940 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;
		for (int i = 0; i < n; i++)r[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[3][i] = true;
			if (y[i] - r[i]<0)col[1][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;
			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 << 3;
			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;
			}
		}
	}
	return 0;
}

Compilation message

park.cpp: In function 'int main()':
park.cpp:58: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 20 ms 504 KB Output is correct
2 Incorrect 18 ms 620 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2523 ms 940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 504 KB Output is correct
2 Incorrect 18 ms 620 KB Output isn't correct
3 Halted 0 ms 0 KB -