QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745257 | #8775. MountainCraft | MiniLong | WA | 1ms | 3964kb | C++14 | 3.5kb | 2024-11-14 08:46:29 | 2024-11-14 08:46:31 |
Judging History
answer
#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
#ifdef ONLINE_JUDGE
char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
#define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
#else
#define get() getchar()
#endif
template<typename T> inline void read(T &t){
T x = 0, f = 1;
char c = getchar();
while(!isdigit(c)){
if(c == '-') f = -f;
c = getchar();
}
while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
t = x * f;
}
template<typename T, typename ... Args> inline void read(T &t, Args&... args){
read(t);
read(args...);
}
template<typename T> void write(T t){
if(t < 0) putchar('-'), t = -t;
if(t >= 10) write(t / 10);
putchar(t % 10 + '0');
}
template<typename T, typename ... Args> void write(T t, Args... args){
write(t), putchar(' '), write(args...);
}
template<typename T> void writeln(T t){
write(t);
puts("");
}
template<typename T> void writes(T t){
write(t), putchar(' ');
}
#undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
const ll mod = 998244353;
ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
void add(ll &x, ll y){x = (x + y) % mod;}
void mul(ll &x, ll y){x = x * y % mod;}
ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 2e5 + 5;
typedef long double lb;
int q;
lb w;
map<PII, bool> vis;
multiset<int> L, R;
void ins(int x, int y){
L.insert(x - y), R.insert(x + y);
}
void del(int x, int y){
L.erase(L.find(x - y)), R.erase(R.find(x + y));
}
struct node{
lb x, y;
node(lb _x = 0, lb _y = 0){x = _x, y = _y;}
node operator+(const node b)const{return node(x + b.x, y + b.y);}
node operator-(const node b)const{return node(x - b.x, y - b.y);}
lb len(){return sqrtl(x * x + y * y);}
};
lb calc(){
if(L.empty()) return 0;
lb x0 = *L.begin(), x1 = *prev(R.end());
lb tx = (x0 + x1) / 2.00, ty = tx - x0;
node u = node(x0, 0), v = node(x1, 0), cur = node(tx, ty);
lb ans = 0;
if(cur.x > 0){
if(u.x < 0) ans += (cur - node(0, -x0)).len();
else ans += (cur - u).len();
}
if(cur.x < w){
if(v.x > w) ans += (cur - node(w, -w + x1)).len();
else ans += (cur - v).len();
}
return ans;
}
int main(){
read(q), scanf("%Lf", &w);
while(q--){
int x, y; read(x, y);
if(vis[{x, y}]) del(x, y), vis[{x, y}] = 0;
else ins(x, y), vis[{x, y}] = 1;
printf("%.10Lf\n", calc());
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3880kb
input:
3 10 3 2 7 3 9 6
output:
5.6568542495 12.7279220614 12.7279220614
result:
ok 3 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
5 100 31 41 59 26 31 41 59 26 31 41
output:
101.8233764909 120.2081528017 73.5391052434 0.0000000000 101.8233764909
result:
ok 5 numbers
Test #3:
score: 0
Accepted
time: 1ms
memory: 3892kb
input:
100 10 6 4 2 3 7 6 5 5 3 6 7 5 5 8 10 4 9 8 0 9 9 10 9 3 2 3 10 10 8 4 10 9 0 1 1 7 0 2 3 4 10 3 3 10 7 4 7 5 1 4 0 7 1 9 5 6 8 8 7 4 8 1 3 9 2 1 5 5 2 1 10 9 8 4 0 9 10 7 4 1 9 10 8 6 5 4 1 4 0 9 9 3 4 8 5 10 7 2 8 10 7 10 3 4 2 2 8 5 0 9 5 3 1 4 6 4 0 3 8 1 1 6 3 8 8 4 6 5 10 2 2 2 8 4 6 1 2 4 6 4...
output:
11.3137084990 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.1421356237 14.142...
result:
ok 100 numbers
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3964kb
input:
1000 100 95 8 54 8 64 96 47 34 77 47 99 91 45 70 8 6 64 84 48 42 53 14 73 66 38 27 6 52 19 75 33 39 6 24 37 80 27 45 96 48 55 95 67 1 23 78 40 4 76 7 77 22 4 47 41 31 60 54 96 37 79 52 63 40 7 92 17 7 74 12 93 16 87 5 67 43 60 29 71 58 52 41 53 84 38 2 46 87 13 54 54 14 16 93 57 7 91 98 31 23 70 3 9...
output:
18.3847763109 76.3675323681 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 141.4213562373 14...
result:
wrong answer 2nd numbers differ - expected: '41.0121933', found: '76.3675324', error = '0.8620690'