QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#67345#5098. 第一代图灵机woshiSB_river10 121ms47632kbC++142.0kb2022-12-10 12:01:132022-12-10 12:01:17

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-10 12:01:17]
  • Judged
  • Verdict: 10
  • Time: 121ms
  • Memory: 47632kb
  • [2022-12-10 12:01:13]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
inline int read()
{   int x=0;
    bool f=0;
    char c=getchar();
    while(!isdigit(c))f|=(c=='-'),c=getchar();
    while(isdigit(c))x=x*10+(c&15),c=getchar();
    return f?-x:x;
}
using namespace std;
int n,m,q,a[200005],id[200005],c[200005],sum[200005][25],maxn;
bool bj[200005];
inline int get_max(int l,int r)
{   int cnt=log2(r-l+1);
    return max(sum[l][cnt],sum[r-(1<<cnt)+1][cnt]);
}
signed main()
{   //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    n=read(),m=read(),q=read();
    for(register int i=1;i<=n;++i)a[i]=read();
    for(register int i=1;i<=n;++i)c[i]=read();
    if(n<=5000&&m<=5000)
    {   for(register int i=1,op,l,r;i<=q;++i)
        {   op=read(),l=read(),r=read();
            if(op==1)
            {   maxn=0;
                int now=0,last=l;
                for(register int j=l;j<=r;++j)
                {   while(last<=r&&bj[c[last]]==0)
                    {   bj[c[last]]=1;
                        now+=a[last];
                        last++;
                    }
                    maxn=max(maxn,now);
                    now-=a[j];
                    bj[c[j]]=0;
                }
                printf("%lld\n",maxn);
            }
            else c[l]=r;
        }
    }
    else
    {   int now=0,last=1;
        for(register int j=1;j<=n;++j)
        {   while(last<=n&&bj[c[last]]==0)
            {   bj[c[last]]=1;
                now+=a[last];
                last++;
            }
            id[last]=j;
            sum[j][0]=now;
            now-=a[j];
            bj[c[j]]=0;
        }
        int len=log2(n);
        for(register int i=1;i<=len;++i)
        {   int up=n-(1<<i)+1;
            for(register int j=1;j<=up;++j)
                sum[j][i]=max(sum[j][i-1],sum[j+(1<<(i-1))][i-1]);
        }
        for(register int i=1,op,l,r;i<=q;++i)
        {   op=read(),l=read(),r=read();
            printf("%lld\n",get_max(l,id[r+1]));
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 25ms
memory: 7572kb

input:

5000 200 5000
2315 3433 1793 4621 4627 4561 289 4399 3822 2392 392 4581 2643 2441 4572 4649 2981 3094 4206 2057 761 2516 2849 3509 3033 658 4965 3316 3269 4284 4961 753 1187 2515 1377 1725 4743 4761 3823 3464 4859 989 2401 953 875 1481 2181 103 2067 2625 3296 4721 61 3843 1607 997 4385 1284 4299 441...

output:

118571
90725
79596
95154
95154
94493
72411
100567
100567
100567
100567
90725
100567
100567
90725
118571
94493
95154
58191
118571
100567
100567
100567
39374
89208
118571
99923
100567
100567
95724
87252
100567
118571
100567
100567
100567
100567
100567
100567
26617
100567
99923
100567
118571
100567
100...

result:

ok 3799 lines

Test #2:

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

input:

5000 1000 5000
451 521 3465 4281 3422 1186 2547 3341 2060 1467 717 2115 2513 2471 1399 1812 3070 2173 521 1621 2801 4020 4493 138 4162 97 1179 171 4011 3340 2393 689 1830 3981 2352 3352 3561 2969 1037 1205 2390 3916 1578 2313 2433 885 1097 1820 739 4483 3241 3861 1547 665 1449 4133 4877 1005 3510 18...

output:

188595
209663
209663
209663
209663
209663
209282
209663
209663
176195
156041
141623
176195
209663
209663
209282
175706
209663
209663
209663
209663
209663
209282
209663
209663
209663
188595
209282
209663
183686
209663
163197
209663
183686
209663
183686
209663
175706
209663
209663
209663
209663
209663...

result:

ok 3724 lines

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 73ms
memory: 47632kb

input:

200000 10 200000
55651 97298 108697 86619 60721 199951 10610 162267 154301 138848 39191 18605 101369 57073 34977 101576 71252 143401 89587 160521 166491 38442 150761 35579 25571 121311 38033 38483 144639 41401 179161 54872 157905 137601 46863 187656 171901 43715 41036 150741 69057 102031 130561 4772...

output:

394441
81407
76295
71671
1232419
1232419
732019
635008
431899
175464
400799
88390
30541
371636
1148070
1232419
1232419
1232419
659489
378168
1206368
330581
1232419
466988
1232419
497166
537124
1222519
1167757
319691
417499
1214212
687183
1222519
200070
549698
190634
1222519
271304
202624
253650
1232...

result:

wrong answer 1st lines differ - expected: '1232419', found: '394441'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 121ms
memory: 47528kb

input:

200000 20000 200000
30681 32496 35471 48191 159123 69792 120915 150673 187226 158493 36275 26856 107976 124777 145229 69745 183961 14497 144808 153612 185893 137681 66417 46802 19345 113322 168046 128149 191001 135433 13201 139214 59489 81178 42343 163158 110121 119201 97501 53079 158755 192241 1132...

output:

10674861
11565528
11035239
5438264
5911160
10582729
27755020
4343302
20726277
16928534
11115858
16836200
21953546
7707481
42801975
11065651
19852826
19886692
8971620
2853352
4804714
27933467
3131169
10220412
4197477
16097273
25973934
3268575
15967677
37191041
1635668
9064292
21438486
5948561
1528301...

result:

wrong answer 1st lines differ - expected: '46702944', found: '10674861'

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #9:

score: 0
Wrong Answer
time: 22ms
memory: 19608kb

input:

50000 1000 50000
22098 40691 15626 6766 15467 15377 43375 7991 25841 6053 2031 38833 19761 42385 9421 28399 42001 15985 31206 30047 14001 7441 8377 5217 4402 37695 41393 25926 38137 32913 23203 31265 31401 32772 32905 24167 5233 24058 41685 26999 41 18461 15721 49365 49676 3151 29237 22894 37323 272...

output:

647187
323237
715141
1224594
823949
2734990
242063
665143
1274254
230022
856706
733776
635892
594731
222297
974125
728365
1141731
637717
932775
298222
374911
1134109
967650
941169
419475
849298
856039
546780
427386
216239
437168
579919
171744
921719
924334
1104862
503018
781595
739442
898292
390539
...

result:

wrong answer 1st lines differ - expected: '2734990', found: '647187'

Subtask #5:

score: 0
Skipped

Dependency #4:

0%