QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#134381#2290. Kinking CablesPetroTarnavskyi#RE 0ms0kbC++171.7kb2023-08-03 18:36:122023-08-03 18:36:15

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-03 18:36:15]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-08-03 18:36:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

vector<pair<db, db>> ans;

const db eps = 1e-6;

int main()
{
	int n, m;
	db l;
	cin >> n >> m >> l;
	db sta = l;
	
	ans.PB(MP(n, m));
	while(true){
		assert(l >= sqrt(n * n + m * m) - eps);
		if(l <= n + m){
			db L = 0, R = m;
			FOR(t, 0, 300){
				db x = (L + R) / 2;
				db val = (m - x) + sqrt(x * x + n * n);
				if(val > l)
					L = x;
				else
					R = x;
			}
			ans.PB(MP(n, R));
			ans.PB(MP(0, 0));
			break;
		}
		l -= m + 1;
		
		ans.PB(MP(n, 0));
		ans.PB(MP(n - 1, 0));
		n--;
		
		if(l <= m + sqrt(n * n + m * m)){			
			db L = 0, R = m;
			FOR(t, 0, 300){
				db x = (L + R) / 2;
				db val = x + sqrt(x * x + n * n);
				if(val > l)
					R = x;
				else
					L = x;
			}
			ans.PB(MP(n, R));
			ans.PB(MP(0, 0));
			break;
		}
		ans.PB(MP(n, m));
		ans.PB(MP(n - 1, m));
		n--;
		assert(n >= 0);
	}
	
	db cur = 0;
	FOR(i, 0, SZ(ans) - 1){
		db x = ans[i].F - ans[i + 1].F;
		db y = ans[i].S - ans[i + 1].S;
		cur += sqrt(x * x + y * y);
	}
	
	//cerr << sta << " " << cur << endl;
	assert(abs(sta - cur) < eps);
	
	
	
	cout << SZ(ans) << endl;
	reverse(ALL(ans));
	cout << fixed << setprecision(8);
	
	FOR(i, 0, SZ(ans))
		cout << ans[i].F << " " << ans[i].S << endl;
	

	
	
	return 0;
}

詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

79 78
1980.7712136406

output:


result: