Submission #1544139


Source Code Expand

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <iomanip>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

#define X first
#define Y second

const int _N = 2e5;
const long double PI = 3.1415926535897932;

int x1,x2,yy1,yy2;
int n;
int cnt[_N];
int ins = 0;
PII p[_N];
bool inside(int x, int y){
	return x1 <= x && x <= x2 &&
			yy1 <= y && y <= yy2;
}
int count(int i){
	if(~cnt[i])return cnt[i];
	if(!inside(p[i].X, p[i].Y)){
		return cnt[i] = 0;
	}
	ins++;
	int c = 0;

	FOR(j, i+1, n){
		if(p[j].Y > p[i].Y){ // right and top
			c = max(c,count(j));
		}
	}
	c++;
	return cnt[i] = c;
}
int main() {
	cin >> x1 >> yy1 >> x2 >> yy2 >> n;
	//init
	REP(i, n)cnt[i] = -1;
	//
	int xk = 1, yk = 1;
	if(x1>x2&&yy1>yy2){
		swap(x1,x2);
		swap(yy1,yy2);
	}else if(x1>x2){
		x1*=-1;x2*=-1;
		xk=-1;
	}else if(yy1>yy2){
		yy1*=-1;yy2*=-1;
		yk=-1;
	}
//	dump(1);
	REP(i, n){
		int xx, yy;
		cin >> xx >> yy;
		p[i] = MP(xx * xk, yy * yk);
	}
//	dump(2);
	sort(p, p+n);
	int M = 0;
//	dump(3);
	REP(i, n){ //count (right and top) s
		M = max(M,count(i));
	}
//	dump(4);
	long double ans = (ll)((x2-x1)+(yy2-yy1)) * 100;
	cout << fixed << setprecision(13);
	cerr << fixed << setprecision(13);
//	dump(M);
//	dump(((x2-x1)+(yy2-yy1)) * 100);
//	dump(ans);
//	dump(M * (5*PI - 20));

	if(M==min((x2-x1),(yy2-yy1))+1){
		ans += (M-1) * (5*PI - 20) - 20 + 10 * PI;
	}else{
		ans += M * (5*PI - 20);
	}
	cout << fixed << setprecision(13) << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - Fountain Walk
User luma
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2577 Byte
Status TLE
Exec Time 2104 ms
Memory 10880 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 29
TLE × 18
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 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 256 KB
subtask_1_03.txt AC 1 ms 256 KB
subtask_1_04.txt AC 1 ms 256 KB
subtask_1_05.txt AC 1 ms 256 KB
subtask_1_06.txt AC 1 ms 256 KB
subtask_1_07.txt AC 1 ms 256 KB
subtask_1_08.txt AC 1 ms 256 KB
subtask_1_09.txt AC 72 ms 1024 KB
subtask_1_10.txt AC 153 ms 1920 KB
subtask_1_11.txt AC 40 ms 640 KB
subtask_1_12.txt TLE 2104 ms 8832 KB
subtask_1_13.txt AC 161 ms 2048 KB
subtask_1_14.txt AC 75 ms 1152 KB
subtask_1_15.txt AC 38 ms 640 KB
subtask_1_16.txt TLE 2104 ms 8832 KB
subtask_1_17.txt AC 132 ms 1792 KB
subtask_1_18.txt AC 114 ms 1408 KB
subtask_1_19.txt AC 465 ms 1408 KB
subtask_1_20.txt TLE 2104 ms 8832 KB
subtask_1_21.txt TLE 2104 ms 10880 KB
subtask_1_22.txt TLE 2104 ms 8832 KB
subtask_1_23.txt TLE 2103 ms 2944 KB
subtask_1_24.txt AC 1 ms 256 KB
subtask_1_25.txt AC 1 ms 256 KB
subtask_1_26.txt AC 1 ms 256 KB
subtask_1_27.txt AC 1 ms 256 KB
subtask_1_28.txt AC 1170 ms 2560 KB
subtask_1_29.txt AC 647 ms 2560 KB
subtask_1_30.txt TLE 2103 ms 2560 KB
subtask_1_31.txt TLE 2103 ms 2560 KB
subtask_1_32.txt TLE 2104 ms 8832 KB
subtask_1_33.txt TLE 2104 ms 5760 KB
subtask_1_34.txt TLE 2103 ms 2560 KB
subtask_1_35.txt TLE 2103 ms 2816 KB
subtask_1_36.txt TLE 2103 ms 2560 KB
subtask_1_37.txt TLE 2104 ms 6912 KB
subtask_1_38.txt TLE 2104 ms 5760 KB
subtask_1_39.txt TLE 2104 ms 4608 KB
subtask_1_40.txt TLE 2104 ms 5760 KB
subtask_1_41.txt TLE 2103 ms 2560 KB