QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#80568#5173. 染色ytczy6660 590ms97468kbC++141.7kb2023-02-24 11:34:372023-02-24 11:34:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-24 11:34:40]
  • 评测
  • 测评结果:0
  • 用时:590ms
  • 内存:97468kb
  • [2023-02-24 11:34:37]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::min;
using std::max;
using std::set;
using std::queue;
using std::sort;
using std::unique;
using std::vector;
using std::pair;
#define ll long long
#define db double
#define inf 0x3f3f3f3f
#define ull unsigned long long
#define F(i,l,r) for(int i=(l);i<=(r);i++)
#define UF(i,l,r) for(int i=(l);i>=(r);i--)
#define mp std::make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define ls(x) x<<1
#define rs(x) x<<1|1
#define pb push_back
inline int rd(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
	return f*x;
}
const int N=1000010;
int n,m,a[N],las[N],pre[N],nxt[N],t[N],ans[N];
vector<pii>qry1[N],qry2[N];
void update(int x,int v){for(int i=x;i<=n;i+=i&-i)t[i]+=v;}
int query(int x){
    int ans=0;
    for(int i=x;i;i^=i&-i)ans+=t[i];
    return ans;
}
int main(){
    n=rd();m=rd();
    F(i,1,n){
        a[i]=rd();pre[i]=las[a[i]];
        las[a[i]]=i;
    }
    F(i,1,n)las[i]=n+1;
    UF(i,n,1){
        nxt[i]=las[a[i]];las[a[i]]=i;
    }
    F(i,1,m){
        int l=rd(),r=rd();
        if(l<=r)qry1[r].pb(mp(l,i)),ans[i]-=(l-1),ans[i]+=(r-l-1);
        else qry2[r].pb(mp(l,i)),ans[i]-=(n-l),ans[i]+=(l-r-1);
    }
    F(i,1,n){
        update(pre[i]+1,1);
        F(j,0,(int)qry1[i].size()-1)ans[qry1[i][j].se]+=query(qry1[i][j].fi);
    }
    memset(t,0,sizeof(t));
    UF(i,n,1){
        update(n+2-nxt[i],1);
        F(j,0,(int)qry2[i].size()-1)ans[qry2[i][j].se]+=query(n+1-qry2[i][j].fi);
    }
    F(i,1,m){
        cout<<ans[i]<<"\n";
    }
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 62508kb

input:

10000 100
84 85 52 2 78 53 20 21 23 76 37 44 18 5 37 8 81 65 46 58 69 1 69 37 53 46 37 35 35 89 1 77 35 6 46 59 89 46 25 55 50 38 61 67 44 23 29 24 46 4 42 15 34 77 20 34 83 79 12 50 69 26 38 14 9 66 80 72 22 26 9 68 35 38 19 84 92 30 83 62 100 71 81 60 7 37 64 50 33 60 86 75 45 78 32 53 3 48 87 60 ...

output:

2011
2487
3216
4469
477
3757
154
3915
348
694
204
1271
6995
3361
327
4019
1223
5568
1033
1491
2604
232
3226
425
3572
3322
6049
1517
1748
4184
9370
360
2960
9398
5089
3306
2703
7703
445
330
8242
6707
4727
4182
5827
3545
3436
2719
4847
4546
1236
5469
1502
6640
2684
1219
4689
1092
3474
1577
597
3578
30...

result:

wrong answer 1st words differ - expected: '3668', found: '2011'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 53ms
memory: 63516kb

input:

100000 100000
3 2 3 3 3 3 2 3 2 1 3 1 1 1 3 2 1 3 1 2 2 1 3 1 2 2 1 1 1 3 2 1 3 3 3 3 1 1 1 2 3 3 2 1 1 1 3 1 3 1 3 2 1 3 2 3 3 2 3 3 2 3 3 3 3 3 2 3 2 3 1 3 3 3 3 3 3 3 1 2 3 3 1 3 1 1 2 2 3 1 1 2 3 2 3 1 3 2 1 3 2 3 2 1 1 3 3 1 3 1 2 2 2 3 2 3 2 3 2 1 1 3 1 3 2 2 3 3 3 1 2 2 3 3 2 1 3 1 2 2 2 3 2 ...

output:

77084
90576
37459
4408
6261
53338
63952
19847
26526
76010
45363
4930
44906
29153
30458
33580
7555
73376
48784
7260
3224
59375
31850
51583
18492
7460
8283
40581
12666
37572
7937
5353
3747
26339
45815
39689
11540
47817
47902
36592
35296
379
12603
81625
2730
29480
42558
23145
6726
17046
22644
49240
142...

result:

wrong answer 1st words differ - expected: '113194', found: '77084'

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 4ms
memory: 61360kb

input:

5000 5000
256 63 197 36 75 66 33 72 27 75 66 248 29 166 209 252 141 95 84 226 147 249 116 94 192 256 199 273 182 166 116 274 27 211 154 144 283 23 53 110 215 11 164 284 161 221 251 96 43 47 18 115 12 51 156 61 116 209 93 98 47 165 174 106 83 67 184 75 12 290 183 197 112 240 67 56 215 148 104 5 141 2...

output:

939
1676
1175
1632
2735
2857
1809
951
673
2893
4299
2785
724
711
637
4022
4221
3028
2249
1951
2589
1080
1592
40
709
270
2529
2285
2247
3233
2661
1129
379
1002
2151
2988
480
112
1333
4196
4964
1339
1892
2181
1774
371
587
2351
171
1951
1007
1098
3945
1835
3347
4435
1066
2244
317
2588
1984
1167
643
154...

result:

wrong answer 1st words differ - expected: '1322', found: '939'

Subtask #4:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 590ms
memory: 97468kb

input:

1000000 1000000
1105 3246 1880 3554 818 2331 2576 4140 149 4562 3498 3536 3400 4788 4363 4742 1216 4218 4032 1701 1489 4889 1761 3022 3145 4945 3067 4304 5016 4624 1612 13 1335 3613 1086 2210 386 3464 1156 3352 4341 5006 3465 3900 622 654 1826 2983 1250 4164 3335 4308 2995 1982 1347 4335 2535 5054 4...

output:

640526
160230
387241
45006
85680
295115
501949
867932
681377
113256
314775
279709
701910
166312
555289
31321
143894
119484
2365
79346
77852
340485
17440
117572
97747
731719
842899
280419
78676
492437
561409
124493
416003
61620
47697
602752
164283
366062
90295
286551
391112
212327
41873
139233
278991...

result:

wrong answer 1st words differ - expected: '1263815', found: '640526'