QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149545#5713. Eggscavationlmeowdn0 2ms10624kbC++143.6kb2023-08-24 20:22:332023-08-24 20:22:35

Judging History

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

  • [2023-08-24 20:22:35]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:10624kb
  • [2023-08-24 20:22:33]
  • 提交

answer

#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
template<typename T,typename U> T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U> T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S> bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S> bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}
 
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii; 
typedef vector<int> vi;
typedef vector<pii> vp;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=2505,M=1e5+5,inf=0x3f3f3f3f;
int T,n,m,k,f[N][N],t[N][N],s[N],v[N];
vp ve[N];
vi vd[N];

void add(int l,int r,int u,int d,int w) {
  f[l][u]+=w, f[r+1][d+1]+=w;
  f[l][d+1]-=w, f[r+1][u]-=w;
}
int lb(int x) {return x&-x;}
void sadd(int x) {for(;x;x-=lb(x)) s[x]++;}
void sdel(int x) {for(;x;x-=lb(x)) s[x]--;}
int qry(int x,int y=0) {for(;x<=m;x+=lb(x)) y+=s[x]; return y;}

namespace SegT {
  int ls[N<<1],rs[N<<1],s[N<<1],tot=1;
  multiset<int> f[N<<1];
  void mdf(int p,int l,int r,int x,int y) {
    if(l==r) {
      if(y>0) f[p].insert(y);
      else f[p].erase(f[p].find(-y));
      s[p]=(f[p].size()?(*f[p].begin()):inf);
      return;
    } int mid=l+r>>1;
    if(x<=mid) mdf(ls[p],l,mid,x,y);
    else if(x>mid) mdf(rs[p],mid+1,r,x,y);
    s[p]=min(s[ls[p]],s[rs[p]]);
  }
  int qry(int p,int l,int r,int x,int y) {
    if(l==x&&r==y) return s[p]; int mid=l+r>>1;
    if(y<=mid) return qry(ls[p],l,mid,x,y);
    else if(x>mid) return qry(rs[p],mid+1,r,x,y);
    else return min(qry(ls[p],l,mid,x,mid),qry(rs[p],mid+1,r,mid+1,y));
  }
  void init(int p,int l,int r) {
    s[p]=inf; if(l==r) return; int mid=l+r>>1;
    init(ls[p]=++tot,l,mid), init(rs[p]=++tot,mid+1,r);
  }
}

signed main() {
  n=read(), k=read(), m=read();
  rep(i,1,m) {
    int K=read(); vp p;
    rep(i,1,K) {
      int x=read(), y=read();
      p.eb(pii(x,y));
    }
    rep(s,1,(1<<K)-1) {
      int l=1,r=N,u=1,d=N,w=popcnt(s)&1?1:-1;
      rep(i,0,K-1) if(s&(1<<i)) {
        chmin(r,p[i].fi), chmax(l,p[i].fi-k+1);
        chmin(d,p[i].se), chmax(u,p[i].se-k+1);
      }
      if(l<=r&&u<=d) add(l,r,u,d,w);
    }
  }
  rep(i,1,n) rep(j,1,n) f[i][j]+=f[i-1][j];
  rep(i,1,n) rep(j,1,n) f[i][j]+=f[i][j-1];
  T=read();
  rep(i,1,T) {
    int opt=read();
    if(opt==1) {
      int x=read(), y=read();
      ve[max(1,x-k+1)].eb(y,i);
      ve[x+1].eb(y,-i);
    } else v[i]=read();
  }
  SegT::init(1,1,n);
  rep(i,1,n-k+1) {
    for(auto [x,y]:ve[i]) SegT::mdf(1,1,n,x,y);
    rep(j,1,n-k+1) t[i][j]=SegT::qry(1,1,n,j,j+k-1);
  }
  rep(i,1,n-k+1) rep(j,1,n-k+1) {
    if(f[i][j]) {
      if(t[i][j]>T) t[i][j]=T;
      vd[t[i][j]].eb(f[i][j]);
      sadd(f[i][j]);
    }
  }
  rep(i,1,T) {
    for(int x:vd[i]) sdel(x);
    if(v[i]) {
      int tot=(n-k+1)*(n-k+1);
      int cnt=qry(v[i]);
      printf("%.5lf\n",1.*cnt/tot);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 3.75
Accepted
time: 2ms
memory: 10624kb

input:

40 5
200
4 25 33 8 25 39 17 7 5
2 25 11 25 17
3 1 21 1 1 25 40
1 1 1
4 25 11 25 18 35 25 16 1
3 6 9 39 1 1 33
1 1 27
1 37 21
3 1 31 25 1 40 13
3 11 33 31 1 21 39
4 36 16 31 17 16 5 31 22
2 3 9 36 19
1 39 25
2 7 11 17 23
2 25 11 3 15
1 29 12
1 37 21
2 1 26 7 36
3 27 5 1 26 35 33
1 37 36
3 15 31 4 1 3...

output:

0.90509
0.88272
0.82330
0.70756
0.58025
0.42978
0.29784
0.20602
0.14043
0.08102
0.04707
0.02315
0.01235
0.00617
0.00540
0.00386
0.00154
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00...

result:

ok 202 numbers

Test #2:

score: 0
Accepted
time: 2ms
memory: 6460kb

input:

40 4
500
1 1 17
3 5 34 21 25 6 39
4 39 31 15 1 3 11 21 21
1 37 21
3 16 2 33 29 36 19
3 12 25 1 5 32 1
3 15 16 31 5 21 11
2 11 19 13 17
1 3 13
1 2 21
1 1 13
1 30 36
1 21 1
1 25 23
3 19 25 37 23 25 9
1 14 1
4 13 33 3 23 2 13 11 6
1 21 3
1 9 25
2 29 11 31 23
1 16 33
1 1 19
4 1 11 17 39 36 37 16 1
1 1 2...

output:

0.90869
0.90358
0.89043
0.85756
0.81300
0.73192
0.63988
0.53470
0.44193
0.32725
0.24982
0.18188
0.12856
0.09131
0.06574
0.05040
0.03798
0.02264
0.01607
0.01096
0.00657
0.00511
0.00438
0.00438
0.00219
0.00073
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00000
0.00...

result:

ok 502 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 6208kb

input:

20 3
300
3 9 6 6 19 13 5
2 2 5 1 1
3 9 9 15 3 20 16
1 4 19
3 16 5 9 13 11 16
1 9 7
4 1 7 4 3 1 17 20 1
1 13 1
1 1 7
1 11 6
2 13 17 6 2
2 20 17 6 1
1 18 6
3 2 7 11 12 3 13
2 11 14 18 7
3 6 7 1 1 3 1
1 17 5
1 1 14
2 6 1 11 5
1 17 14
1 9 13
3 13 19 15 2 1 9
2 12 11 1 11
2 7 5 17 19
1 17 18
3 13 20 2 2 ...

output:

0.94136
0.94136
0.93519
0.91358
0.87654
0.83951
0.78395
0.71914
0.63272
0.55247
0.45988
0.40741
0.34877
0.30247
0.23457
0.19136
0.14506
0.11111
0.08025
0.05556
0.03395
0.03086
0.02469
0.01543
0.00617
0.00617
0.00309
0.00309
0.00309
0.00309
0.00309
0.00309
0.00309
0.00000
0.00000
0.00000
0.00000
0.00...

result:

ok 302 numbers

Test #4:

score: -3.75
Runtime Error

input:

40 1
100000
2 15 39 9 23
3 23 38 33 30 35 1
2 9 1 13 11
4 9 29 39 33 25 29 39 11
3 10 25 17 3 4 5
3 1 17 10 3 13 24
3 27 1 19 21 34 15
3 11 26 23 1 19 25
1 5 1
1 24 17
1 39 5
3 1 39 15 40 7 19
1 15 21
2 14 4 12 33
1 33 31
1 21 25
3 25 5 31 19 1 28
4 37 23 3 25 39 11 26 33
2 37 22 4 18
3 39 31 2 23 3...

output:

26.44187
24.87750
24.87813
23.31250
24.88062
23.31375
23.31437
21.74625
24.88812
23.31812
23.31625
21.74375
23.31312
21.73500
21.73313
20.15000
24.87125
23.28187
23.26750
21.67625
23.23813
21.64750
21.63437
20.05063
23.20188
21.61750
21.61188
20.02563
21.60625
20.02062
20.01875
18.43000
24.78063
23....

result:


Subtask #2:

score: 0
Runtime Error

Test #6:

score: 0
Runtime Error

input:

999 300
10000
1 667 804
3 769 412 909 315 471 651
1 869 932
4 404 590 541 271 36 897 244 108
1 963 94
1 269 811
1 595 213
1 25 284
3 439 438 295 715 279 962
1 216 784
1 568 255
3 2 597 406 118 298 177
1 936 559
1 976 187
2 989 163 306 923
3 391 211 513 163 968 193
2 22 670 524 543
1 65 371
3 7 619 8...

output:

0.43967
0.43457
0.43457
0.42946
0.43458
0.42946
0.42946
0.42434
0.43460
0.42948
0.42948
0.42435
0.42949
0.42435
0.42436
0.41922
0.43467
0.42952
0.42953
0.42438
0.42953
0.42439
0.42439
0.41923
0.42956
0.42440
0.42440
0.41924
0.42441
0.41925
0.41925
0.41408
0.43483
0.42966
0.42966
0.42448
0.42967
0.42...

result:


Subtask #3:

score: 0
Runtime Error

Test #13:

score: 0
Runtime Error

input:

2500 1111
4000
1 751 1336
2 1077 2296 1305 1997
1 161 2337
3 75 720 1197 1725 2311 1609
1 2149 1221
3 105 1711 1961 1727 1181 2055
1 1913 871
2 1164 924 783 486
3 215 1722 1621 1807 1638 1176
4 801 1989 483 1149 561 878 261 2245
4 839 2247 526 2413 573 2431 1218 775
3 2201 909 1002 197 778 2451
1 40...

output:


result: