QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134383 | #2290. Kinking Cables | PetroTarnavskyi# | RE | 2ms | 3828kb | C++17 | 1.7kb | 2023-08-03 18:39:06 | 2023-08-03 18:39:10 |
Judging History
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;
}
l -= m + 1;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3724kb
input:
79 78 1980.7712136406
output:
49 0.00000000 0.00000000 56.00000000 72.31127465 56.00000000 0.00000000 57.00000000 0.00000000 57.00000000 78.00000000 58.00000000 78.00000000 58.00000000 0.00000000 59.00000000 0.00000000 59.00000000 78.00000000 60.00000000 78.00000000 60.00000000 0.00000000 61.00000000 0.00000000 61.00000000 78.00...
result:
ok correct
Test #2:
score: 0
Accepted
time: 2ms
memory: 3828kb
input:
33 65 1947.7601065763
output:
61 0.00000000 0.00000000 4.00000000 16.64308721 4.00000000 0.00000000 5.00000000 0.00000000 5.00000000 65.00000000 6.00000000 65.00000000 6.00000000 0.00000000 7.00000000 0.00000000 7.00000000 65.00000000 8.00000000 65.00000000 8.00000000 0.00000000 9.00000000 0.00000000 9.00000000 65.00000000 10.00...
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
51 51 555.0803652025
output:
21 0.00000000 0.00000000 42.00000000 33.41160772 42.00000000 0.00000000 43.00000000 0.00000000 43.00000000 51.00000000 44.00000000 51.00000000 44.00000000 0.00000000 45.00000000 0.00000000 45.00000000 51.00000000 46.00000000 51.00000000 46.00000000 0.00000000 47.00000000 0.00000000 47.00000000 51.00...
result:
ok correct
Test #4:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
49 2 67.3588717350
output:
21 0.00000000 0.00000000 40.00000000 0.35727619 40.00000000 0.00000000 41.00000000 0.00000000 41.00000000 2.00000000 42.00000000 2.00000000 42.00000000 0.00000000 43.00000000 0.00000000 43.00000000 2.00000000 44.00000000 2.00000000 44.00000000 0.00000000 45.00000000 0.00000000 45.00000000 2.00000000...
result:
ok correct
Test #5:
score: -100
Dangerous Syscalls
input:
37 48 1713.3643608504