QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622024#4339. 青蛙题 / rmscnerotcar070 2664ms152716kbC++201.6kb2024-10-08 19:31:242024-10-08 19:31:26

Judging History

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

  • [2024-10-08 19:31:26]
  • 评测
  • 测评结果:0
  • 用时:2664ms
  • 内存:152716kb
  • [2024-10-08 19:31:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e6+5;
int n,q;
#define ls p<<1
#define rs p<<1|1
struct seg1{
    int t[maxn<<2],g[maxn<<2];
    inline void pushup(int p){t[p]=min(t[ls],t[rs]);}
    inline void pushdown(int p,int l,int mid){
        if(g[p]){
            g[ls]=g[rs]=g[p];
            t[ls]=g[p]-l+1; 
            t[rs]=g[p]-mid;
            g[p]=0;
        }
    }
    void modify(int p,int l,int r,int ql,int qr,int k){
        if(ql<=l&&r<=qr) return t[p]=k-l+1,g[p]=k,void();
        int mid=l+r>>1;
        pushdown(p,l,mid);
        if(ql<=mid) modify(ls,l,mid,ql,qr,k);
        if(qr>mid) modify(rs,mid+1,r,ql,qr,k);
        pushup(p);
    }
    int query(int p,int l,int r,int ql,int qr){
        // cout<<p<<' '<<l<<' '<<r<<' '<<g[p]<<' '<<t[p]<<'\n';
        if(ql<=l&&r<=qr) return t[p];
        int mid=l+r>>1,res=n+1;pushdown(p,l,mid);
        if(ql<=mid) res=query(ls,l,mid,ql,qr);
        if(qr>mid) res=min(res,query(rs,mid+1,r,ql,qr));
        return res;
    }
}A;
int lst[maxn],a[maxn],fa[maxn];
vector<pair<int,int>> Q[maxn];
int ans[maxn];
inline int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
int main(){
    cin>>n;for(int i=1;i<=n;i++) cin>>a[i],fa[i]=i;cin>>q;
    for(int i=1,x,y;i<=q;i++) cin>>x>>y,Q[y].emplace_back(x,i);
    for(int i=1;i<=n;i++){
        int x=lst[a[i]];A.modify(1,1,n,x+1,i,i);fa[getfa(x)]=getfa(x+1);
        lst[a[i]]=i;
        for(auto [x,id]:Q[i]) ans[id]=A.query(1,1,n,x,getfa(x));
    }
    for(int i=1;i<=q;i++) cout<<ans[i]<<'\n';cout<<'\n';
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 46ms
memory: 11308kb

input:

49877
5 19104 10024 26645 44019 3799 47144 18957 16261 7730 49099 47900 6246 42506 7445 29494 29292 23364 40488 16750 6800 21668 27296 36297 18566 37148 15851 40842 5872 11177 46903 1732 38477 12305 27376 35840 33232 36691 34829 20037 36492 33175 40983 7253 13581 2 4603 3443 22203 49583 38890 14550 ...

output:

308
2669
29667
1994
4345
2206
9867
9432
6497
15313
4691
35920
2504
13085
18158
43914
7180
24316
10061
27156
1061
20341
15979
32174
9761
41891
33530
8350
7624
7071
28284
17944
37105
24743
12990
2822
11094
26076
15015
6211
5570
38782
3664
8493
8295
3086
2482
16262
17710
4164
1998
21064
40701
9000
7959...

result:

wrong answer 5th numbers differ - expected: '4344', found: '4345'

Subtask #2:

score: 0
Wrong Answer

Test #13:

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

input:

4681
11 7 2524 4128 1315 4444 205 750 3112 932 1690 3540 3647 461 3547 2873 1944 1617 1439 85 4106 3897 2853 6 3270 1159 1636 5 2966 4463 4288 688 1982 1274 4454 4270 3129 4255 118 4549 4266 7 7 1347 3638 1280 4022 2901 368 2238 3 2750 2987 3218 3507 6 1137 983 4327 2867 1155 2096 7 414 1564 10 1044...

output:

571
348
1396
2748
1171
1119
2183
3117
2050
2759
1122
1913
584
1188
2343
1766
3730
3166
997
112
836
563
210
2082
1853
2808
1686
2459
276
2143
2414
371
3031
1035
2437
3656
4407
100
3670
1905
383
2309
3090
2422
2316
2740
450
4081
1756
2657
524
1447
2444
79
694
366
2752
1291
1980
3039
518
790
855
2114
5...

result:

wrong answer 1st numbers differ - expected: '570', found: '571'

Subtask #3:

score: 0
Wrong Answer

Test #25:

score: 0
Wrong Answer
time: 2664ms
memory: 152716kb

input:

1927935
1307002 177803 328035 1844109 5 532876 1638997 1111173 1392421 1704007 241552 613377 262779 4 1823788 394795 52876 11 8 1103445 1293860 1033234 1745826 249295 670713 1452644 1891635 331608 933251 1531742 559293 291541 732326 969795 1592807 8 1358796 1389801 1074221 1709205 945430 726546 1488...

output:

727848
1026164
1233157
552414
388216
432550
74976
700049
8114
452986
612727
137410
933681
469414
253893
451868
899632
25552
1341719
1197525
744046
198241
186021
635522
875168
424572
1846218
952996
808896
843011
89400
864211
402012
167625
283143
1010292
113288
259012
549760
67737
1259389
1780006
1565...

result:

wrong answer 5th numbers differ - expected: '388215', found: '388216'