Submission #1542100


Source Code Expand

#pragma region Template
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <stack>
#include <set>
#include <algorithm>
#include <bitset>
#include <functional>
#include <ctime>
#include <cassert>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <complex>
#include <regex>
#include <numeric>
#pragma comment(linker, "/STACK:167772160")

using namespace std;
#define mp make_pair
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define print_var(x) cerr << #x << " : " << (x) << endl
#define print_array(arr, len) {cerr << #arr << " : "; for(int i = 0; i < len; ++i) cerr << arr[i] << ' '; cerr << endl;}
#define print_2d_array(arr, len1, len2) {cerr << #arr << endl; for(int i = 0; i < len1; ++i, cerr << endl) for(int j = 0; j < len2; ++j) cerr << arr[i][j] << ' ';}
#define print_iterable(i) {cerr << #i << " : "; for(auto e : i) cerr << e << ' '; cerr << endl;}
#define print_new_line() cerr << endl

template <typename T, typename Q>
void print_pair1(pair<T, Q> x)
{
	cerr << "(" << x.first << ", " << x.second << ")\n";
}

#define print_pair(x) {cerr << #x << " : "; print_pair1(x);}
#else
#define print_pair(x) (void)0
#define eprintf(...) (void)0
#define print_var(x) (void)0
#define print_array(arr, len) {}
#define print_2d_array(arr, len1, len2) {}
#define print_iterable(i) {}
#define print_new_line() (void)0
#endif

#define rand govno_ebanoe

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int INF = (int)1e9 + 10;
const ll LINF = ll(2e18) + 10;
const double PI = acosl(-1);
const double eps = 1e-8;
const ld EPS = 1e-12;
#pragma endregion

#ifdef LOCAL
#define ERR_CATCH
//#define NOERR
#endif

const int N = 2e5 + 10;
int n;
pii pts[N];
pii s, f;
vector<int> xs;
vector<int> ys;

struct Segt
{
	int arr[4 * N];
	Segt() : arr() {}
	void add(int ind, int l, int r, int p, int v)
	{
		arr[ind] = max(arr[ind], v);
		if (l == r)
			return;
		auto m = (l + r) / 2;
		if (p <= m)
			add(ind * 2, l, m, p, v);
		else
			add(ind * 2 + 1, m + 1, r, p, v);
	}
	void add(int p, int v)
	{
		add(1, 0, N - 1, p, v);
	}
	int get(int ind, int l, int r, int R)
	{
		if (r <= R)
			return arr[ind];
		if (R < l)
			return 0;
		auto m = (l + r) / 2;
		return max(get(ind * 2, l, m, R), get(ind * 2 + 1, m + 1, r, R));
	}
	int get(int R)
	{
		return get(1, 0, N - 1, R);
	}
} segt;

pii trans(pii p)
{
	auto x = (lower_bound(xs.begin(), xs.end(), p.first) - xs.begin());
	auto y = (lower_bound(ys.begin(), ys.end(), p.second) - ys.begin());
	return { x, y };
}

void solve()
{
	scanf("%d%d%d%d", &s.first, &s.second, &f.first, &f.second);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", &pts[i].first, &pts[i].second);
	if (s.first > f.first)
	{
		s.first = -s.first;
		f.first = -f.first;
		for (int i = 0; i < n; ++i)
			pts[i].first = -pts[i].first;
	}
	if (s.second > f.second)
	{
		s.second = -s.second;
		f.second = -f.second;
		for (int i = 0; i < n; ++i)
			pts[i].second = -pts[i].second;
	}
	auto n = f.first - s.first;
	auto m = f.second - s.second;
	double manh = (n + m) * 100.0;
	xs.push_back(s.first);
	xs.push_back(f.first);
	for (int i = 0; i < n; ++i)
		xs.push_back(pts[i].first);
	ys.push_back(s.second);
	ys.push_back(f.second);
	for (int i = 0; i < n; ++i)
		ys.push_back(pts[i].second);
	sort(xs.begin(), xs.end());
	xs.resize(unique(xs.begin(), xs.end()) - xs.begin());
	sort(ys.begin(), ys.end());
	ys.resize(unique(ys.begin(), ys.end()) - ys.begin());
	s = trans(s);
	f = trans(f);
	for (int i = 0; i < n; ++i)
		pts[i] = trans(pts[i]);
	sort(pts, pts + n);
	int mx = 0;
	for(int i = 0 ; i < n; ++i)
	{
		auto p = pts[i];
		if (p.first < s.first || p.first > f.first || p.second < s.second || p.second > f.second)
			continue;
		auto cur = segt.get(p.second) + 1;
		mx = max(mx, cur);
		segt.add(p.second, cur);
	}
	print_var(mx);
	print_var(manh);
	if (mx == min(n, m) + 1)
		manh += 10 * PI / 2;
	printf("%.13lf\n", manh + mx * 10 * (PI / 2 - 2));
}

int main()
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#ifdef NOERR
	freopen("err.txt", "w", stderr);
#endif
#else
	//freopen("knight.in", "r", stdin);
	//freopen("knight.out", "w", stdout);
#endif

#ifdef ERR_CATCH
	try
	{
#endif

#ifdef ST
		while (true)
			solve();
#endif
#ifdef CASES
#define MULTITEST
#endif
#ifdef MULTITEST
		int t;
		scanf("%d", &t);
		char endl1[5];
		fgets(endl1, 5, stdin);
		for (int i = 0; i < t; ++i)
		{
#ifdef CASES
			printf("Case #%d: ", i + 1);
#endif
			solve();
#ifdef CASES
			eprintf("Passed case #%d:\n", i + 1);
#endif
		}
#else
		solve();
#endif

#ifdef ERR_CATCH
	}
	catch (logic_error e)
	{
		print_var(e.what());
		puts("___________________________________________________________________________");
		exit(0);
	}
#endif
#ifdef LOCAL
	eprintf("\n\nTime: %.3lf\n", double(clock()) / CLOCKS_PER_SEC);
#endif
}

Submission Info

Submission Time
Task C - Fountain Walk
User tinsane
Language C++14 (GCC 5.4.1)
Score 0
Code Size 5423 Byte
Status RE
Exec Time 160 ms
Memory 7284 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:129:61: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &s.first, &s.second, &f.first, &f.second);
                                                             ^
./Main.cpp:130:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
./Main.cpp:132:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &pts[i].first, &pts[i].second);
                                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 22
WA × 8
RE × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt, subtask_1_28.txt, subtask_1_29.txt, subtask_1_30.txt, subtask_1_31.txt, subtask_1_32.txt, subtask_1_33.txt, subtask_1_34.txt, subtask_1_35.txt, subtask_1_36.txt, subtask_1_37.txt, subtask_1_38.txt, subtask_1_39.txt, subtask_1_40.txt, subtask_1_41.txt
Case Name Status Exec Time Memory
sample_01.txt AC 3 ms 4352 KB
sample_02.txt AC 3 ms 4352 KB
sample_03.txt AC 3 ms 4352 KB
subtask_1_01.txt WA 3 ms 4352 KB
subtask_1_02.txt AC 3 ms 4352 KB
subtask_1_03.txt AC 3 ms 4352 KB
subtask_1_04.txt AC 3 ms 4352 KB
subtask_1_05.txt AC 3 ms 4352 KB
subtask_1_06.txt AC 3 ms 4352 KB
subtask_1_07.txt AC 3 ms 4352 KB
subtask_1_08.txt AC 3 ms 4352 KB
subtask_1_09.txt WA 16 ms 4352 KB
subtask_1_10.txt WA 30 ms 4480 KB
subtask_1_11.txt WA 10 ms 4352 KB
subtask_1_12.txt WA 160 ms 7284 KB
subtask_1_13.txt RE 128 ms 5752 KB
subtask_1_14.txt RE 111 ms 5496 KB
subtask_1_15.txt RE 104 ms 5496 KB
subtask_1_16.txt RE 135 ms 6136 KB
subtask_1_17.txt WA 27 ms 4352 KB
subtask_1_18.txt RE 117 ms 5496 KB
subtask_1_19.txt RE 116 ms 5496 KB
subtask_1_20.txt RE 133 ms 6136 KB
subtask_1_21.txt AC 160 ms 7284 KB
subtask_1_22.txt RE 136 ms 6136 KB
subtask_1_23.txt WA 160 ms 7284 KB
subtask_1_24.txt AC 3 ms 4352 KB
subtask_1_25.txt AC 3 ms 4352 KB
subtask_1_26.txt AC 3 ms 4352 KB
subtask_1_27.txt AC 3 ms 4352 KB
subtask_1_28.txt WA 78 ms 6008 KB
subtask_1_29.txt RE 135 ms 6136 KB
subtask_1_30.txt RE 136 ms 6136 KB
subtask_1_31.txt AC 92 ms 7284 KB
subtask_1_32.txt AC 104 ms 7284 KB
subtask_1_33.txt AC 92 ms 7284 KB
subtask_1_34.txt AC 95 ms 7284 KB
subtask_1_35.txt RE 136 ms 6136 KB
subtask_1_36.txt RE 136 ms 6136 KB
subtask_1_37.txt RE 136 ms 6136 KB
subtask_1_38.txt RE 137 ms 6136 KB
subtask_1_39.txt RE 136 ms 6136 KB
subtask_1_40.txt RE 135 ms 6136 KB
subtask_1_41.txt RE 138 ms 6136 KB