Submission #426204

# Submission time Handle Problem Language Result Execution time Memory
426204 2021-06-13T15:12:31 Z 8e7 IOI Fever (JOI21_fever) C++14
6 / 100
1 ms 204 KB
//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
void debug() {cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){ cout << a << " ";debug(b ...);};
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
//using namespace __gnu_pbds;
pii a[maxn];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int val[maxn], type[maxn];
int solve(int n) {
	//pary(val, val + n);
	bool in[n];
	for (int i = 0;i < n;i++) in[i] = 0;
	in[0] = 1;
	vector<pair<ll, pii>> ev;
	for (int i = 0;i < n;i++) {
		for (int j = i + 1;j < n;j++) {
			if (val[i] % 2 != val[j] % 2) {
				pii inter;
				ll dx = 0, dy = 0;
				if (val[i] % 2) {
					inter = {a[i].ff, a[j].ss};
					dy = (a[j].ss - a[i].ss) / dir[val[i]][1];
					dx = (a[i].ff - a[j].ff) / dir[val[j]][0];
				} else {
					inter = {a[j].ff, a[i].ss};
					dy = (a[i].ss - a[j].ss) / dir[val[j]][1];
					dx = (a[j].ff - a[i].ff) / dir[val[i]][0];
				}
				if (dx > 0 && dy > 0 && dx == dy) {
					ev.push_back(make_pair(dx, make_pair(i,j)));
				}	
			}
		}
	}
	sort(ev.begin(), ev.end());
	for (auto i:ev) {
		if (in[i.ss.ff] || in[i.ss.ss]) {
			in[i.ss.ff] = in[i.ss.ss] = 1;
		}
	}
	int cnt = 0;
	for (int i = 0;i < n;i++) cnt += in[i] ? 1 : 0;
	return cnt;
}
int main() {
	io
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i].ff >> a[i].ss;
	}
	int ans = 1;
	val[0] = 1;
	for (int i = 1;i < n;i++) {
		val[i] = 2;
	}
	ans = max(ans, solve(n));
	val[0] = 0;
	for (int i = 1;i < n;i++) val[i] = 3;
	ans = max(ans, solve(n));
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -