QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#395163#686. Bad DoctorSroundWA 203ms30624kbC++141.5kb2024-04-21 09:35:232024-04-21 09:35:24

Judging History

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

  • [2024-04-21 09:35:24]
  • 评测
  • 测评结果:WA
  • 用时:203ms
  • 内存:30624kb
  • [2024-04-21 09:35:23]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

inline int read()
{
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=1;ch=getchar();}
	while(ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return f?-x:x;
}

#define x first
#define y second
#define pb push_back
#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 long long LL;
typedef unsigned long long ull;
const int N=5e5+10;

int n,m;
int c[N],s[N],nums[N],cnt;
LL sum,f[N];
struct Node{int l,r,id;}; vector<Node> p[N];

bool cmp(Node &a,Node &b) {return a.l<b.l;}
void find(int &x) {x=lower_bound(nums+1,nums+1+cnt,x)-nums;}

int main()
{
	n=read(),m=read();
	rep(i,1,m) c[i]=read();
	for(int i=1,l,r,s,x;i<=n;i++) {
		l=read(),r=read(),s=read();
		while(s--) x=read(),p[x].pb({l,r+1,i});
	}
	
	for(int i=1;i<=m;i++) {
		sort(p[i].begin(),p[i].end(),cmp),cnt=0;
		for(auto t:p[i]) nums[++cnt]=t.l,nums[++cnt]=t.r;
		sort(nums+1,nums+1+cnt),cnt=unique(nums+1,nums+1+cnt)-nums-1,nums[cnt+1]=nums[cnt];
		rep(i,0,cnt) s[i]=0;
		for(int j=0;j<(int)p[i].size();j++) find(p[i][j].l),find(p[i][j].r);
		for(auto t:p[i]) s[t.l]++,s[t.r]--;
		
		int tot=0;
		rep(i,1,cnt) s[i]+=s[i-1],tot+=(s[i]>0)*(nums[i+1]-nums[i]);
		rep(i,1,cnt) s[i]=s[i-1]+(s[i]==1)*(nums[i+1]-nums[i]);
		sum+=(LL)tot*c[i];
		for(auto t:p[i]) f[t.id]+=(LL)(s[t.r-1]-s[t.l-1])*c[i];
	}
	
	rep(i,1,n) printf("%lld ",sum-f[i]);
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 4
1000 100 10 1
3 4 2 2 3
4 8 3 1 2 4
6 7 2 3 4
8 9 2 1 4
2 6 3 1 2 3

output:

8766 7564 8756 7765 6646 

result:

ok 5 number(s): "8766 7564 8756 7765 6646"

Test #2:

score: 0
Accepted
time: 0ms
memory: 23056kb

input:

1 1
1
1 1 1 1

output:

0 

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 22148kb

input:

1 2
10 1
1 2 1 2

output:

0 

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 4ms
memory: 22812kb

input:

2 1
1
1 2 1 1
3 4 1 1

output:

2 2 

result:

ok 2 number(s): "2 2"

Test #5:

score: 0
Accepted
time: 4ms
memory: 21964kb

input:

2 1
1
1 2 1 1
2 3 1 1

output:

2 2 

result:

ok 2 number(s): "2 2"

Test #6:

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

input:

1 3
1000000 909090 700700
1 1000000 3 1 2 3

output:

0 

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 0ms
memory: 21316kb

input:

2 1
1000000
1 500000 1 1
500000 1000000 1 1

output:

500001000000 500000000000 

result:

ok 2 number(s): "500001000000 500000000000"

Test #8:

score: 0
Accepted
time: 0ms
memory: 22164kb

input:

2 2
10 1
3 8 1 1
5 9 1 2

output:

5 60 

result:

ok 2 number(s): "5 60"

Test #9:

score: 0
Accepted
time: 0ms
memory: 23052kb

input:

2 2
10 1
3 8 2 1 2
5 9 1 2

output:

5 66 

result:

ok 2 number(s): "5 66"

Test #10:

score: 0
Accepted
time: 0ms
memory: 21892kb

input:

2 2
10 1
3 8 2 1 2
5 6 1 1

output:

20 66 

result:

ok 2 number(s): "20 66"

Test #11:

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

input:

2 2
10 1
6 6 2 1 2
2 2 1 2

output:

1 11 

result:

ok 2 number(s): "1 11"

Test #12:

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

input:

2 2
10 1
6 6 1 2
1 2 1 2

output:

2 1 

result:

ok 2 number(s): "2 1"

Test #13:

score: 0
Accepted
time: 0ms
memory: 22520kb

input:

3 1
1
1 6 1 1
3 16 1 1
8 11 1 1

output:

14 10 16 

result:

ok 3 number(s): "14 10 16"

Test #14:

score: 0
Accepted
time: 0ms
memory: 21344kb

input:

3 1
1
1 8 1 1
3 15 1 1
5 12 1 1

output:

13 12 15 

result:

ok 3 number(s): "13 12 15"

Test #15:

score: 0
Accepted
time: 0ms
memory: 23208kb

input:

3 2
10 1
1 6 2 1 2
4 9 1 1
5 10 1 2

output:

66 70 96 

result:

ok 3 number(s): "66 70 96"

Test #16:

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

input:

3 2
10 1
1 6 2 1 2
7 9 1 1
3 6 1 2

output:

34 66 96 

result:

ok 3 number(s): "34 66 96"

Test #17:

score: 0
Accepted
time: 0ms
memory: 21292kb

input:

3 2
10 1
1 3 2 1 2
5 6 1 1
8 12 1 2

output:

25 38 53 

result:

ok 3 number(s): "25 38 53"

Test #18:

score: 0
Accepted
time: 0ms
memory: 21460kb

input:

3 2
10 1
1 8 1 1
1 1 1 2
3 4 2 1 2

output:

23 82 81 

result:

ok 3 number(s): "23 82 81"

Test #19:

score: 0
Accepted
time: 0ms
memory: 21344kb

input:

3 3
100 10 1
3 5 2 2 3
8 8 1 2
8 8 2 1 3

output:

111 134 43 

result:

ok 3 number(s): "111 134 43"

Test #20:

score: 0
Accepted
time: 0ms
memory: 21728kb

input:

5 5
10000 1000 100 10 1
1 4 1 4
7 9 2 4 5
8 10 5 1 2 3 4 5
5 6 4 1 2 3 4
2 3 3 1 2 4

output:

77584 77593 44293 55384 55604 

result:

ok 5 number(s): "77584 77593 44293 55384 55604"

Test #21:

score: 0
Accepted
time: 4ms
memory: 22184kb

input:

10 7
552910 150933 995175 215236 872242 381236 155576
2 9 2 1 3
5 8 4 1 3 4 7
13 20 2 2 4
17 19 4 1 2 3 6
16 19 4 3 4 5 7
6 10 4 1 2 6 7
16 16 4 1 4 5 7
6 12 3 3 4 7
14 16 4 2 3 6 7
12 18 4 1 2 3 5

output:

41574799 45848242 45207177 44522436 44880084 43005299 46219054 43056608 44764194 39372338 

result:

ok 10 numbers

Test #22:

score: 0
Accepted
time: 5ms
memory: 22212kb

input:

7 10
736484 818923 456465 12520 997843 981585 612726 181577 186139 168089
3 11 4 2 7 8 10
1 4 1 1
12 13 6 1 2 3 5 6 7
10 14 3 2 6 9
17 20 5 3 4 5 6 8
3 13 2 1 7
20 20 2 2 6

output:

40495012 47901499 46465851 44680094 39836092 44219079 48555544 

result:

ok 7 numbers

Test #23:

score: 0
Accepted
time: 4ms
memory: 23140kb

input:

30 10
857308 953250 600059 683156 139561 641008 542233 928243 893627 191827
2 22 2 5 8
29 50 2 1 3
47 48 3 7 8 10
21 22 2 8 9
42 45 3 3 6 9
4 27 4 5 6 8 10
45 50 1 8
26 39 3 1 4 10
40 44 5 6 7 8 9 10
44 46 5 1 4 6 7 9
44 44 3 1 8 10
2 24 5 3 6 7 8 10
4 39 2 3 4
40 46 2 3 4
30 45 5 1 2 7 8 9
10 45 3 ...

output:

293838811 290066769 292754345 292051557 293838811 293646984 293838811 292879676 293005976 292402951 293838811 287917175 285973327 291106187 284902541 291127646 267465483 281328033 293838811 293699250 293838811 293838811 293315596 290979061 293838811 292514647 293838811 293838811 293838811 293838811 

result:

ok 30 numbers

Test #24:

score: 0
Accepted
time: 0ms
memory: 21920kb

input:

10 30
391716 868283 902120 388402 981355 289714 570338 351001 196034 286794 661345 223544 480989 228068 668284 480867 671125 927397 983725 983858 967588 276597 257618 199614 61676 473411 45932 450727 45681 368382
11 26 7 1 13 14 15 16 19 27
15 16 4 13 14 29 30
19 46 4 6 21 22 30
37 38 6 9 10 18 20 2...

output:

123670461 171088996 119574830 165992964 169391754 153780399 165654628 148473523 166617345 168366240 

result:

ok 10 numbers

Test #25:

score: 0
Accepted
time: 0ms
memory: 23036kb

input:

60 40
214784 374560 331541 383120 553085 21716 253180 156648 54233 898460 696585 177744 806924 494782 17110 123004 611634 437506 349347 472426 960396 841591 117777 2457 743805 923885 808421 626506 444686 822906 738699 897414 751402 715382 174480 428567 525859 418878 139239 73165
43 94 2 4 34
73 86 1...

output:

1286380648 1288526794 1287651782 1283846804 1287658154 1280320699 1254862714 1287023990 1288514509 1287558232 1274668519 1288526794 1285120582 1261510038 1287007714 1286808665 1217981437 1288526794 1287552121 1288526794 1282578830 1286766918 1287478927 1279195034 1284937138 1268832042 1288526794 127...

result:

ok 60 numbers

Test #26:

score: 0
Accepted
time: 0ms
memory: 23084kb

input:

40 60
432564 15941 218898 381405 944405 622234 901280 644715 561289 369329 730603 514677 977787 810908 656473 232857 767720 878754 732768 319462 580706 196541 515660 633761 862798 740252 717437 351747 274470 884642 524838 3384 279161 303717 166799 106145 290214 443696 285588 707603 248932 403905 578...

output:

1521415473 1507270535 1517038227 1514380823 1513870185 1492434944 1508816703 1474941708 1485455736 1505592494 1518157381 1451068000 1519494183 1471167676 1517031855 1514809221 1490573182 1516619035 1520254617 1511020126 1455246571 1495439950 1515754649 1484130967 1520939771 1492389078 1496487626 152...

result:

ok 40 numbers

Test #27:

score: 0
Accepted
time: 0ms
memory: 22676kb

input:

100 50
157617 567295 279380 280193 657430 128267 559638 21581 945026 885826 677464 647180 311530 842012 76705 816983 673923 87222 839864 280237 66121 894351 175723 666480 871548 487243 177099 42342 380062 144691 501870 873145 195318 221491 488364 683896 52175 255195 124899 758996 532153 367647 82898...

output:

3692970391 3688368381 3692970391 3686375123 3674040877 3692970391 3691718191 3692970391 3677909003 3689477811 3638603893 3691966651 3692970391 3692970391 3692970391 3681343828 3576516275 3678811171 3690448258 3690135313 3687076307 3692970391 3692970391 3692970391 3659449541 3692970391 3677282527 369...

result:

ok 100 numbers

Test #28:

score: 0
Accepted
time: 4ms
memory: 21344kb

input:

50 100
794804 326387 72887 924307 232451 519528 601019 407798 56835 594796 65959 496043 671546 207428 101058 826245 496147 131382 293881 779360 885979 832974 511964 428055 431364 579226 578335 524555 366245 381871 723034 7587 343799 218210 979146 842118 372890 518159 660686 192290 32334 698453 54353...

output:

5130008628 4808728036 4975217735 5026093311 5124798868 5078109332 4900978059 5118767978 5118735484 5070095030 5111926749 4947276146 5078258499 5114790747 5121109765 4995857479 5073437520 4985034828 5008414458 5127352388 5113848491 5068341358 5116516098 5114753764 4902482956 5130008628 5124417520 492...

result:

ok 50 numbers

Test #29:

score: -100
Wrong Answer
time: 203ms
memory: 30624kb

input:

500000 1
54323
737748 903520 1 1
692152 810006 1 1
12758 725821 1 1
127813 525491 1 1
872352 906159 1 1
10758 527461 1 1
778715 934980 1 1
320837 869940 1 1
224623 345649 1 1
7817 31142 1 1
991366 991656 1 1
312156 778301 1 1
516424 673463 1 1
824263 896790 1 1
160414 565103 1 1
994004 999732 1 1
30...

output:

487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060 487060...

result:

wrong answer 1st numbers differ - expected: '54323000000', found: '487060'