QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390940#3270. 魔塔 OL27455185850 3ms40964kbC++202.1kb2024-04-16 09:12:362024-04-16 09:12:36

Judging History

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

  • [2024-04-16 09:12:36]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:40964kb
  • [2024-04-16 09:12:36]
  • 提交

answer

#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=10001,M=15;
int n,m,q,f1[N][N/M],f2[N][N/M],f3[N][N/M],f4[N][N/M];
ll g1[N/M][1<<M],g2[N/M][1<<M];
struct str
{
    int l,r,x,y,z,a,b;
}a[N];
struct
{
    int t,x,y,z;
}b[N];
void add(int *a,int x)
{
    a[x/M]^=(1<<(x%M));
}
bool cmp(str a,str b)
{
    if((a.a<a.b)^(b.a<b.b)) return a.a<a.b;
    if(a.a<a.b) return a.a<b.a;
    else return a.b>b.b;
}
int main()
{
    scanf("%d",&m);
    for(int i=1;i<=m;++i)
    {
        char z;
        scanf("%s",&z);
        if(z=='+')
        {
            ++n;
            scanf("%d%d%d%d%d",&a[n].x,&a[n].y,&a[n].z,&a[n].a,&a[n].b);
            a[n].l=i;
            a[n].r=m+1;
        }
        else if(z=='-')
        {
            int x;
            scanf("%d",&x);
            a[x].r=i;
        }
        else if(z=='?')
        {
            ++q;
            scanf("%d%d%d",&b[q].x,&b[q].y,&b[q].z);
            b[q].t=i;
        }
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=n;++i)
    {
        add(f1[a[i].l],i);
        add(f1[a[i].r],i);
        add(f2[a[i].x],i);
        add(f3[a[i].y],i);
        add(f4[a[i].z],i);
    }
    for(int i=1;i<=m;++i)
    {
        for(int j=0;j<=n/M;++j)
        {
            f1[i][j]^=f1[i-1][j];
            f2[i][j]^=f2[i-1][j];
            f3[i][j]^=f3[i-1][j];
            f4[i][j]^=f4[i-1][j];
        }
    }
    for(int i=0;i<=n/M;++i)
    {
        for(int j=0;j<=(1<<M)-1;++j)
        {
            ll s=0,w=0;
            for(int k=0;k<=M-1;++k)
            {
                if((j&(1<<k))==0) continue;
                w-=a[i*M+k].a;
                s=min(s,w);
                w+=a[i*M+k].b;
            }
            g1[i][j]=s,g2[i][j]=w;
        }
    }
    for(int i=1;i<=q;++i)
    {
        ll s=0,w=0;
        for(int j=0;j<=n/M;++j)
        {
            int p=f1[b[i].t][j]&f2[b[i].x][j]&f3[b[i].y][j]&f4[b[i].z][j];
            s=min(s,w+g1[j][p]);
            w+=g2[j][p];
        }
        printf("%lld\n",-s);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Accepted
time: 3ms
memory: 12052kb

input:

10
+ 2 1 1 3 4
+ 1 2 2 2 5
? 2 2 2
+ 1 1 1 8 2
? 2 2 1
? 1 2 2
- 1
? 2 2 2
- 3
? 1 2 2

output:

2
7
5
5
2

result:

ok 5 lines

Test #2:

score: -3
Wrong Answer
time: 0ms
memory: 40964kb

input:

24
+ 1753 1095 4823 848018166 5601858
+ 3635 2923 7293 78801729 4982097
+ 4314 6396 5125 589512425 8363663
? 8152 8403 6056
+ 9016 7943 8050 764333567 3409718
? 3516 8598 7385
? 1126 7574 1443
+ 2684 1515 2348 83534456 3012204
- 5
? 1861 8978 2163
- 4
? 480 2246 9251
- 1
+ 3844 6148 4596 110822346 7...

output:

0
0
0
0
0
0
0
0

result:

wrong answer 1st lines differ - expected: '1429166928', found: '0'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Runtime Error

Test #24:

score: 0
Runtime Error

input:

150000
+ 588 392 1 640173034 0
? 7190 2026 1
? 8338 9467 1
+ 332 5522 1 648776911 0
? 650 9239 1
? 6609 1361 1
+ 6028 8919 1 315490561 0
+ 6129 3818 1 716541323 0
+ 2679 2249 1 94302018 0
? 4777 8851 1
+ 1382 186 1 295931805 0
+ 3956 7752 1 275694182 0
+ 6412 2498 1 363908456 0
+ 8317 3132 1 2800724...

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #33:

score: 0
Runtime Error

input:

150000
? 5 2 1
+ 4 2 1 783649445 157723097
+ 3 4 1 281409092 43289613
+ 2 3 2 673972686 123253436
? 3 5 3
? 4 2 3
+ 5 5 2 534941804 768558960
+ 2 4 4 103433782 913423755
+ 1 2 3 99618767 608469807
+ 5 4 4 852574365 108454346
? 4 5 5
+ 1 2 4 647253960 383418735
+ 1 5 1 854207792 811999048
+ 4 2 4 995...

output:


result:


Subtask #5:

score: 0
Runtime Error

Test #47:

score: 0
Runtime Error

input:

150000
+ 9842 1 1 26088315 73696334
+ 2239 1 1 340356927 653719371
+ 349 1 1 632186088 849099938
? 908 1 1
+ 5153 1 1 487261860 697113681
? 984 1 1
+ 5694 1 1 800262114 571078829
? 1152 1 1
+ 3322 1 1 855670925 826813576
+ 8218 1 1 45843349 617723019
+ 3988 1 1 641119549 840483348
+ 3253 1 1 1654789...

output:


result:


Subtask #6:

score: 0
Skipped

Dependency #1:

0%