QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109008#1857. PlayerUnknown's Battlegrounds1kri#TL 3ms8584kbC++141.2kb2023-05-27 08:25:232023-05-27 08:25:25

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-27 08:25:25]
  • 评测
  • 测评结果:TL
  • 用时:3ms
  • 内存:8584kb
  • [2023-05-27 08:25:23]
  • 提交

answer

#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
int n,m,a[305][305];
int x[100005],y[100005];
int book[305][305];
int ans[100005];
int id[305][305],id_tot;
struct DSU{
	int book[305];
	int dsu[305],sz[305];
	int dsu_find(int x){
		while(x!=dsu[x])x=dsu[x]=dsu[dsu[x]];
		return x;
	}
	int add(int x){
		dsu[x]=x,sz[x]=1;
		book[x]=1;
		int p0=1,p1=1;
		if (x>1&&book[x-1]==1){
			int qwq=dsu_find(x-1);
			p0+=sz[qwq];
			dsu[qwq]=x;
			sz[x]+=sz[qwq],sz[qwq]=0;
		}
		if (x<m&&book[x+1]==1){
			int qwq=dsu_find(x+1);
			p1+=sz[qwq];
			dsu[qwq]=x;
			sz[x]+=sz[qwq],sz[qwq]=0;
		}
		return p0*p1;
	}
}dsu[50005];
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			scanf("%d",&a[i][j]);
			x[a[i][j]]=i;
			y[a[i][j]]=j;
		}
	for (int i=1;i<=n;i++)
		for (int j=i;j<=n;j++)
			id[i][j]=++id_tot;
	for (int i=n*m;i>=1;i--){
		int _x=x[i],_y=y[i];
		book[_x][_y]=1;
		for (int j=_x;j>=1;j--){
			if (book[j][_y]==0)break;
			for (int k=_x;k<=n;k++){
				if (book[k][_y]==0)break;
				ans[i]+=dsu[id[j][k]].add(_y);
			}
		}
	}
	for (int i=1;i<=n*m;i++)printf("%d\n",ans[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3648kb

input:

2 3
2 5 1
6 3 4

output:

6
4
5
1
1
1

result:

ok 6 lines

Test #2:

score: 0
Accepted
time: 3ms
memory: 8584kb

input:

50 50
274 1151 2130 502 862 1007 692 1789 1912 37 59 805 2056 891 1341 673 2436 1647 1925 1226 2209 2134 511 1308 1881 1692 1885 216 2321 1032 1106 334 893 720 2269 45 1069 2031 1891 370 40 1916 1790 1671 269 1343 349 509 137 9
2386 1275 834 1519 1896 1729 66 2049 872 262 2240 1813 943 968 475 2051 ...

output:

126360
37360
101052
189734
44388
58160
65320
201549
700
51480
7914
29608
23733
68146
15910
2508
7050
22338
2568
13820
39615
24063
17767
24217
3448
14760
4134
2862
3216
5190
8696
4324
25084
1422
16247
3712
1179
1868
2653
1495
11534
3536
7942
4479
746
6282
915
6734
6350
8724
6556
6150
2452
15366
12494...

result:

ok 2500 lines

Test #3:

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

input:

50 50
1486 846 1348 2280 1801 1630 1057 2035 323 2469 1053 2260 2277 2042 1591 2411 674 2116 498 2077 812 1872 691 708 2262 2130 1296 293 1915 1881 1592 2239 2303 1099 1833 2017 2021 1264 1543 2022 2498 421 1715 1995 393 790 1397 676 2418 1555
2218 1749 1664 697 1762 1462 800 1058 502 1358 309 497 8...

output:

277992
33319
214360
115155
17358
4830
17400
127440
105450
11644
16704
7400
44097
6393
13710
49596
5562
10080
8112
10060
28078
14262
1206
18779
15016
2712
22512
20870
11370
6180
6634
16716
4884
2865
8462
5840
612
5091
8166
2572
9942
7112
1434
1561
1337
4800
5048
6268
3996
2548
8964
7436
1286
4622
559...

result:

ok 2500 lines

Test #4:

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

input:

50 50
2138 647 2428 2499 1570 1856 1404 2335 211 1993 1780 1162 646 410 705 1883 732 2036 1329 1436 1000 216 2011 1202 1524 671 48 946 1811 941 299 1779 2250 1160 488 1469 2295 1163 1808 1886 1372 1217 1434 2060 1758 2349 414 986 1662 2085
1502 718 585 66 1988 2339 813 331 2419 246 38 593 2265 46 17...

output:

300352
78320
225170
16296
32757
46656
24400
7542
17048
67973
33512
33931
8688
37713
48200
16344
36000
7333
3575
14442
79926
1970
18516
10296
4762
11880
3240
406
9922
5954
5964
16860
2055
4036
669
802
1926
3418
414
4636
25615
365
3226
9721
5852
890
9450
972
13285
1350
2752
480
5812
9433
2258
11728
21...

result:

ok 2500 lines

Test #5:

score: -100
Time Limit Exceeded

input:

300 300
62869 36574 33553 12817 22897 15133 47681 36233 67491 54917 41006 49014 48160 44060 77045 79875 17268 87377 12861 38227 3522 81853 49342 29811 24853 60983 88195 36678 63004 36708 16597 40920 84626 70608 42409 47374 89927 53727 43606 83716 58162 10492 76055 13968 54935 31604 38043 36699 56552...

output:


result: