QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149547#5713. Eggscavationlmeowdn3.75 452ms91132kbC++143.6kb2023-08-24 20:23:572023-08-24 20:23:58

Judging History

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

  • [2023-08-24 20:23:58]
  • 评测
  • 测评结果:3.75
  • 用时:452ms
  • 内存:91132kb
  • [2023-08-24 20:23:57]
  • 提交

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[M],v[M];
vp ve[M];
vi vd[M];

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: 3.75
Accepted

Test #1:

score: 3.75
Accepted
time: 3ms
memory: 12324kb

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: 0ms
memory: 12972kb

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: 3ms
memory: 11612kb

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: 0
Accepted
time: 12ms
memory: 12796kb

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:

0.99375
0.99375
0.99375
0.99375
0.99375
0.99375
0.99375
0.99375
0.99375
0.99313
0.99062
0.98875
0.98500
0.97875
0.97625
0.96625
0.95688
0.94188
0.92688
0.91125
0.89500
0.88125
0.86750
0.86187
0.85125
0.84625
0.84000
0.83437
0.83188
0.82812
0.82563
0.82000
0.81625
0.81250
0.80437
0.79563
0.78312
0.77...

result:

ok 9990 numbers

Test #5:

score: 0
Accepted
time: 19ms
memory: 12692kb

input:

40 39
100000
1 33 16
1 1 11
2 21 17 19 35
3 25 30 38 34 4 24
3 6 1 9 35 14 25
3 1 9 11 29 25 38
1 21 29
1 35 26
2 7 25 25 36
1 16 14
3 21 19 7 29 1 9
3 11 31 29 29 17 31
4 6 19 21 1 11 37 1 29
4 7 21 25 33 38 33 13 20
3 25 7 1 9 22 33
1 21 1
4 11 31 4 22 1 13 5 25
3 26 36 8 5 28 40
1 17 37
2 31 1 4 ...

output:

1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00...

result:

ok 10000 numbers

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 6.25
Accepted
time: 42ms
memory: 25448kb

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.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33617
0.33...

result:

ok 9990 numbers

Test #7:

score: 0
Accepted
time: 452ms
memory: 91132kb

input:

2500 50
100000
1 1525 336
1 1493 1542
3 1097 468 337 2479 1525 2037
3 405 361 2293 1705 1482 1336
1 228 1541
1 1491 741
1 2218 2429
3 241 893 1979 1436 753 1011
4 980 1191 393 1401 1116 470 742 301
3 532 539 434 481 101 278
2 1724 2021 977 2186
1 1695 2385
1 2241 1549
1 2358 83
4 457 1001 531 795 17...

output:

0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96012
0.96...

result:

ok 9900 numbers

Test #8:

score: 0
Accepted
time: 203ms
memory: 54808kb

input:

2500 1200
100000
1 651 585
4 1185 627 1696 1895 1851 930 478 531
3 401 585 1037 1451 2256 2
4 223 2201 751 1817 2219 960 2237 926
4 413 1715 696 2091 251 726 1077 189
3 693 1223 1618 419 985 2116
3 291 1 2219 2461 1993 1742
1 321 209
4 988 1051 637 2257 1853 1171 569 362
3 1938 2164 1538 2250 1451 2...

output:

0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44539
0.44...

result:

ok 9998 numbers

Test #9:

score: 0
Accepted
time: 37ms
memory: 36004kb

input:

2500 2500
100000
1 291 1635
1 1676 876
2 837 2076 2313 2317
4 1021 416 575 1773 1077 891 349 1141
2 745 1365 2349 1695
1 1321 281
1 259 1681
2 1341 329 931 105
1 1092 1909
3 146 1463 1781 1641 2103 469
1 1306 201
1 257 2255
3 2451 1473 751 2001 2227 645
3 2016 2489 101 1313 2325 1389
4 631 331 145 1...

output:

1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00000
1.00...

result:

ok 10000 numbers

Test #10:

score: 0
Accepted
time: 415ms
memory: 67820kb

input:

2499 600
98765
3 1996 16 1592 999 292 1585
1 9 2307
1 1926 1136
1 1852 2389
1 393 2441
4 1264 2078 1163 1783 795 929 2413 971
1 1870 934
1 1723 1093
1 887 357
1 1225 676
1 2341 1303
1 1118 685
4 1392 558 337 331 1324 495 2066 2248
3 1968 273 337 1204 811 1594
3 829 1786 2241 95 1501 1429
1 1356 2389...

output:

0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28661
0.28...

result:

ok 9980 numbers

Test #11:

score: -6.25
Wrong Answer
time: 236ms
memory: 59484kb

input:

2500 1105
100000
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 ...

output:

0.06841
0.06837
0.06834
0.06829
0.06826
0.06822
0.06819
0.06815
0.06811
0.06807
0.06803
0.06799
0.06794
0.06790
0.06786
0.06782
0.06777
0.06772
0.06768
0.06764
0.06759
0.06755
0.06751
0.06746
0.06742
0.06738
0.06733
0.06728
0.06724
0.06719
0.06714
0.06710
0.06706
0.06701
0.06697
0.06693
0.06689
0.06...

result:

wrong answer 99th numbers differ - expected: '0.06278', found: '0.00000', error = '0.06278'

Subtask #3:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 209ms
memory: 59448kb

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:

0.38532
0.38490
0.33532
0.30625
0.38076
0.37907
0.37672
0.37211
0.37080
0.37608
0.37486
0.37425
0.37332
0.35911
0.37178
0.36466
0.35788
0.37055
0.37055
0.36997
0.36587
0.27618
0.36749
0.35913
0.32173
0.28209
0.36315
0.36341
0.36501
0.17947
0.28929
0.36500
0.34149
0.36500
0.33245
0.36500
0.36500
0.33...

result:

wrong answer 660th numbers differ - expected: '0.11631', found: '0.00000', error = '0.11631'