QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#818428#5098. 第一代图灵机lgvc10 1498ms28164kbC++232.2kb2024-12-17 20:14:022024-12-17 20:14:04

Judging History

This is the latest submission verdict.

  • [2024-12-17 20:14:04]
  • Judged
  • Verdict: 10
  • Time: 1498ms
  • Memory: 28164kb
  • [2024-12-17 20:14:02]
  • Submitted

answer

#include <bits/stdc++.h>
#define LL long long
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
    if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
    *pp++=ch;
}
inline void pcc(){
    fwrite(buf2,1,pp-buf2,stdout);
    pp=buf2;
}
inline int read(void){
    register int x(0);register char c(getchar());
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x;
}
void write(LL x){
    static int sta[20];
    int top=0;
    do{
        sta[top++]=x%10,x/=10;
    }while(x);
    while(top) pc(sta[--top]+48);
}
void we(LL x){
    write(x);
    pc('\n');
}
int N,M,Q,c[200009],la[200009],pre[200009];
std::set<int> ss[200009];
LL a[200009];
void up(int x) {
    auto it=ss[c[x]].find(x);
    if(it==ss[c[x]].begin()) pre[x]=0;
    else {
        it--;
        pre[x]=(*it);
    }
}
signed main(void) {
    N=read();M=read();Q=read();
    for(int i=1;i<=N;i++) {
        a[i]=read();
        a[i]+=a[i-1];
    }
    for(int i=1;i<=N;i++) {
        c[i]=read();
        pre[i]=la[c[i]];
        la[c[i]]=i;
        ss[c[i]].insert(i);
    }
    for(int i=1;i<=Q;i++) {
        int op=read();
        if(op==2) {
            int x=read(),w=read(),i1=0,i2=0;
            auto it=ss[c[x]].find(x);
            it++;
            if(it!=ss[c[x]].end()) {
                i1=(*it);
            }
            ss[c[x]].erase(x);
            c[x]=w;
            ss[w].insert(x);
            auto it2=ss[w].find(x);
            it2++;
            if(it2!=ss[w].end()) {
                i2=(*it2);
            }
            if(i1) up(i1);
            if(i2) up(i2);
            up(x);
        } else {
            int l=read(),r=read();
            int ma=l-1;LL ans=0;
            #pragma GCC unroll 4
            for(int i=l;i<=r&&i<=l+10000;i++) {
                if(ma<pre[i]) {
                    ans=std::max(ans,a[i-1]-a[ma]);
                    ma=pre[i];
                }
            }
            ans=std::max(ans,a[r]-a[ma]);
            we(ans);
        }
    }
    pcc();
}

詳細信息

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 7ms
memory: 18132kb

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: 10
Accepted
time: 7ms
memory: 18148kb

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
Time Limit Exceeded

Test #3:

score: 0
Time Limit Exceeded

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:


result:


Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 1498ms
memory: 28164kb

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:

5634669348
12381091080
38383720
1644530383
38615532
8553820766
2025056742
8869391988
12406228740
1854596133
27438528
38402892
2342698516
12420036503
11324732985
2920825657
3247407383
3196150998
16917349748
3655193740
11155224350
4408249662
2390366455
718122986
10966395972
1566062192
13758258905
2868...

result:

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

Subtask #4:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #9:

score: 0
Wrong Answer
time: 384ms
memory: 21108kb

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:

234486360
2469610
521986080
244738592
2734990
1967019
737409466
309318580
392762373
2388133
1799671
75270731
253554188
606213110
183702203
1957691
9860927
1952934
135170847
2168141
167700338
96958179
595933316
2469610
60188807
2273183
1986640
433908913
2152587
2152587
186318985
1957691
521774586
195...

result:

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

Subtask #5:

score: 0
Skipped

Dependency #4:

0%