ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#211276 | #3802. 印章 | drdilyor | 100 | 1836ms | 130280kb | C++11 | 1.5kb | 2024-08-10 11:28:59 | 2024-08-10 12:38:55 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
void ts(){cout<<"IAKIOI\n";}
bool Mbe;
inline int read(){
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
int w,l,n,m;
char s[2005][2005];
int dif[4005][4005];
void solve(){
w=read(),l=read(),n=read(),m=read();
for(int i=1;i<=n;i++){
s[i][1]=getchar();
while(s[i][1]!='#'&&s[i][1]!='.')s[i][1]=getchar();
for(int j=2;j<=m;j++)s[i][j]=getchar();
}
for(int i=1;i<=2*n+1;i++)for(int j=1;j<=2*m+1;j++)dif[i][j]=0;
//压缩 n+1~w-n.
//w-n+1 to n+2
//压缩 m+1~l-m.
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(s[i][j]=='#'){
//x1[n]=i,y[n]=j,x2[n]=w-n+i+1,y2[n]=l-m+j+1;
int f=i,g=j;
int p=w-n+i;
if(w>2*n)p-=w,p+=2*n+1;
int q=l-m+j;
if(l>2*m)q-=l,q+=2*m+1;
dif[f][g]++,dif[p+1][q+1]++;
dif[p+1][g]--,dif[f][q+1]--;
}
}
}
for(int i=1;i<=2*n+1;i++){
for(int j=1;j<=2*m+1;j++)dif[i][j]+=dif[i-1][j]+dif[i][j-1]-dif[i-1][j-1];
}
int res=0;
for(int i=1;i<=2*n+1;i++){
for(int j=1;j<=2*m+1;j++){
if(!dif[i][j])continue;
int tmp=1;
if(w>2*n&&i==n+1)tmp*=(w-2*n);
if(l>2*m&&j==m+1)tmp*=(l-2*m);
res+=tmp;
}
}
printf("%lld\n",res);
}
bool Med;
signed main(){
//cerr<<(&Med-&Mbe)/1048576.00<<"MB\n";
int t=read();
while(t--)solve();
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 3ms
memory: 1440kb
input:
2040 20 2 1 1 . 24 4 1 2 .# 24 3 5 2 .# #. .. .# ## 36 35 1 4 #..# 1 47 1 7 ##..#.# 4 9 2 7 ....... ...
output:
0 72 71 1260 47 0 173 899 40 58 81 1147 194 63 515 455 1166 1230 671 42 21 0 32 802 275 405 262 832 ...
result:
ok 2040 tokens
Test #2:
score: 5
Accepted
time: 2ms
memory: 1444kb
input:
3691 50 41 1 1 # 10 43 5 4 .... .... .... .... #... 3 1 2 1 . # 13 8 7 7 ####..# #.#.... .....## ..#...
output:
2050 240 2 100 70 1268 251 239 351 0 331 153 44 1070 0 6 1512 206 287 123 24 1338 0 1967 108 2 700 8...
result:
ok 3691 tokens
Test #3:
score: 5
Accepted
time: 0ms
memory: 1752kb
input:
307 19 2 1 1 . 4 6 3 3 #.. ### #.# 1 11 1 8 .#####.. 16 7 10 5 .###. .###. ##... .#.#. .###. ...#. #...
output:
0 22 8 93 1666 72 216 137 341 73 32 431 605 100 267 0 105 218 447 315 228 308 559 291 491 66 135 460...
result:
ok 307 tokens
Test #4:
score: 5
Accepted
time: 0ms
memory: 1748kb
input:
1151 2 2 1 2 ## 4 90 2 1 # . 4 3 2 2 .. .. 55 39 8 8 ....#... ......#. ...#..#. #......# ##.#...# .....
output:
4 270 0 2127 0 66 162 157 156 102 243 752 132 2969 38 579 34 93 204 585 211 28 5692 99 4221 193 220 ...
result:
ok 1151 tokens
Test #5:
score: 5
Accepted
time: 95ms
memory: 1276kb
input:
142992 1 71640447 1 5 .#.#. 1 32 1 16 .##..#.#.##.#.## 1 128754717 1 13 #...#.#####.# 1 412912033 1 ...
output:
71640445 31 128754717 412912031 975015166 0 29 444235501 674661506 11 706613090 47732810 277285597 2...
result:
ok 142992 tokens
Test #6:
score: 5
Accepted
time: 111ms
memory: 1276kb
input:
182430 1 462437573 1 2 .. 1 4 1 2 #. 2 2 1 1 # 1 117654376 1 6 .#..## 1 3 1 2 ## 1 4 1 4 ...# 1 2 1 ...
output:
0 3 4 117654375 3 1 1 0 7299890 14 990167632 457436593 696745646 6 4 5694018 768431164 992637478 865...
result:
ok 182430 tokens
Test #7:
score: 5
Accepted
time: 115ms
memory: 1304kb
input:
167051 949063550 696367111 1 9 #.####... 2 5 1 4 .... 18713003 154314157 1 6 ...... 144789507 649449...
output:
660896639621713400 0 0 94033480021082343 14 0 13 3886181550 12 0 12660865871664577 12134798759558046...
result:
ok 167051 tokens
Test #8:
score: 5
Accepted
time: 133ms
memory: 1304kb
input:
182067 1 970907619 1 5 ..... 1 11 1 6 ..#.#. 588221550 1 1 1 # 1 16 1 8 ###.#.#. 1 13 1 9 .#...#... ...
output:
0 8 588221550 15 9 0 22 0 16 0 4 4 7306729569 1151777238 15 0 1 1194881000 14660025372894864 4912625...
result:
ok 182067 tokens
Test #9:
score: 5
Accepted
time: 2ms
memory: 2364kb
input:
49 518642469 504232726 3 66 ...#...............#............#................................. ........
output:
261516504407313028 453106527 5119122350 186 232064064928356632 98029571878906 8250 9105531720 279588...
result:
ok 49 tokens
Test #10:
score: 5
Accepted
time: 0ms
memory: 2500kb
input:
340 2 305388993 1 1 # 6 450728609 3 12 ............ ............ ..#......... 23 55 12 32 #.#...###....
output:
610777986 1802914392 1263 173 905130490 1288224615 340953318379437403 262 470 12 83 17801964522 1063...
result:
ok 340 tokens
Test #11:
score: 5
Accepted
time: 35ms
memory: 13972kb
input:
9859 39 2 27 1 . . . . . . . . . . . . . . . . . . . . . . . # . . . 464574874 21687964 9 3 ... .#. ...
output:
26 10075683120928562 108447284 245291486 463190331 85 4396927262 1723136818 124 2211684557 399320240...
result:
ok 9859 tokens
Test #12:
score: 5
Accepted
time: 30ms
memory: 12420kb
input:
5532 283728969 997644030 17 11 #.........# ........#.. ..#........ ........... #...#...#.. #.....#.....
output:
283060512060905035 7568717471 11755017428 9772809760 289 59 924 2150950717 23223134428 55 443 158767...
result:
ok 5532 tokens
Test #13:
score: 5
Accepted
time: 34ms
memory: 29132kb
input:
419 61075512 474658573 4 11 ###...#.... .....#...## ###..###..# #.##.#..### 2 42 2 24 ...#.....####....
output:
28990015371164372 79 269111273231907261 1579097258 1630 1894031183 17382440916 1370334595 4007068763...
result:
ok 419 tokens
Test #14:
score: 5
Accepted
time: 31ms
memory: 42380kb
input:
116 658506323 6 2 6 ...... .....# 2 465009927 2 3 .#. ### 4 2 2 2 .. .. 3 109507599 2 4 ##.. ...# 47...
output:
658506322 930019852 0 328522792 11124126442454398 749984144 27 17 540149509775851048 342292476691275...
result:
ok 116 tokens
Test #15:
score: 5
Accepted
time: 50ms
memory: 12416kb
input:
498 217 913116486 174 8 ...#...# ........ ........ #.##.... .......# #....... ........ ........ .......
output:
198146277411 1023 57899579977927847 31565622824 368848973333502232 90997334277172225 196242839064 25...
result:
ok 498 tokens
Test #16:
score: 5
Accepted
time: 179ms
memory: 42404kb
input:
1152 6 45902942 3 1000 ................................................................................
output:
0 209376371680076696 4649 1479505163498 430166073598 11036 2205890710 4864004338 0 3036345585 861188...
result:
ok 1152 tokens
Test #17:
score: 5
Accepted
time: 163ms
memory: 42356kb
input:
3328 5 710527822 4 200 .............................................#..................................
output:
3552638778 231664700376 3842432301 40587828167 49855445094 328 5888 955734665747130 28266696684 2652...
result:
ok 3328 tokens
Test #18:
score: 5
Accepted
time: 170ms
memory: 130280kb
input:
248 625825389 5 4 3 .## .#. #.. .## 27877511 627106582 3 2 .# #. .. 2317584 8 3 6 .#...# ..#... ...#...
output:
3129126942 17482170010770818 16223080 627483052088124075 50311269489675719 4836850842 9 389067633985...
result:
ok 248 tokens
Test #19:
score: 5
Accepted
time: 266ms
memory: 1300kb
input:
165923 21611739 641706900 9 3 ..# ... #.. ... .#. ... .## ... ... 283865732 7 2 6 ####.. ....#. 3146...
output:
13868400753885292 1703194387 33719183009361319 155779528596017395 73594557356941127 224310909 520151...
result:
ok 165923 tokens
Test #20:
score: 5
Accepted
time: 417ms
memory: 25800kb
input:
566 579629199 26826670 3 2000 .........................................................................
output:
15548651746488490 72730965527677259 262198 1601640231360 247151829066901122 31172 294503530114315099...
result:
ok 566 tokens
Extra Test:
score: 0
Extra Test Passed