QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67372#5098. 第一代图灵机woshiSB_river0 109ms50724kbC++142.3kb2022-12-10 12:17:262022-12-10 12:18:08

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:18:08]
  • Judged
  • Verdict: 0
  • Time: 109ms
  • Memory: 50724kb
  • [2022-12-10 12:17:26]
  • 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],pre[200005],id[200005],c[200005],sum[200005][25],nextt[200005],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(),pre[i]=pre[i-1]+a[i];
    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;
        nextt[0]=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;
            nextt[j]=last;
            sum[j][0]=now;
            now-=a[j];
            bj[c[j]]=0;
        }
        for(register int i=1;i<=n+1;++i)
            if(id[i]==0)id[i]=id[i-1];
        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",max(get_max(l,id[r+1]),pre[r]-pre[id[r+1]]));
        }
    }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 10256kb

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
34719
14618
30437
73739
90725
79596
38157
95154
95154
94493
40832
72411
100567
79842
62567
34147
100567
100567
71068
100567
90725
100567
100567
90725
118571
94493
40346
95154
58191
118571
100567
100567
34287
100567
57034
51575
89208
118571
99923
100567
100567
95724
87252
100567
118571
43892
1...

result:

wrong answer 2nd lines differ - expected: '90725', found: '34719'

Subtask #2:

score: 0
Wrong Answer

Test #3:

score: 0
Wrong Answer
time: 109ms
memory: 50724kb

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:

1232419
1222519
1232419
1232419
1232419
1232419
732019
635008
587850
1232419
1232419
1232419
1232419
1040511
1148070
1232419
1232419
1232419
1232419
1206368
1206368
330581
1232419
587850
1232419
1232419
537124
1222519
1167757
1206368
587850
1214212
687183
1222519
1232419
1222519
190634
1222519
27130...

result:

wrong answer 7th lines differ - expected: '1232419', found: '732019'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 99ms
memory: 50656kb

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:

46702944
46702944
38383720
38615532
38615532
42801975
39035571
46702944
46702944
46702944
27438528
38402892
46702944
46702944
42801975
42323113
39035571
42323113
46702944
46702944
46702944
41821993
46702944
34075405
46702944
38615532
46702944
28680653
46702944
42801975
42801975
38025842
46702944
467...

result:

wrong answer 264th lines differ - expected: '6566847', found: '23284583'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%