QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#742264#5173. 染色2024tangjiaqi0 14ms3988kbC++141.1kb2024-11-13 16:13:352024-11-13 16:13:39

Judging History

This is the latest submission verdict.

  • [2024-11-13 16:13:39]
  • Judged
  • Verdict: 0
  • Time: 14ms
  • Memory: 3988kb
  • [2024-11-13 16:13:35]
  • Submitted

answer

//created by fqr & cyx in 2024
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
#define ll long long
#define pb emplace_back
int ff,Ch;
template <typename T> inline void rd(T &x) {
    x=0,ff=1,Ch=getchar();
    while((Ch<'0'||Ch>'9') && Ch!='-') Ch=getchar();
    if(Ch=='-')Ch=getchar(),ff=-1;
    while(Ch>='0' && Ch<='9') {
        x=(x<<1)+(x<<3)+Ch-'0';
        Ch=getchar();
    }
    x*=ff;
}
template <typename T,typename ...Args> inline void rd(T &x,Args &...args) {
    rd(x), rd(args...);
}
using namespace std;
const int N=1e4+5;
int n,Q;
int mp[N];
int a[N];
signed main() {
//	freopen("color.in","r",stdin);
//	freopen("color.out","w",stdout);
	rd(n),rd(Q);
	for(int i=1,lst; i<=n; i++)
		rd(a[i]);
	int l,r;
	while(Q--) {
		rd(l),rd(r);	
		if(l>r) swap(l,r);
		memset(mp,0,sizeof(mp));
		int ans=r-l;
		for(int i=l+1; i<=r; i++)
			if(a[i]!=a[i-1])
				ans++;
		for(int i=l,p=0; i<=r; i++) {
			if(mp[a[i]]>p && mp[a[i]]!=i-1)
				ans--,p=i;
			mp[a[i]]=i;
		}
		printf("%d\n",ans);
	}
    return 0;
}
/*

*/

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3872kb

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:

3670
4585
5985
8392
730
7021
182
7331
495
1145
254
2255
13246
6267
457
7520
2164
10502
1794
2680
4807
294
6008
628
6667
6189
11431
2715
3164
7847
17811
512
5496
17866
9580
6158
5002
14599
668
465
15636
12691
8885
7845
11002
6612
6407
5033
9115
8541
2179
10314
2695
12556
4966
2149
8823
1909
6484
2837...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 1ms
memory: 3864kb

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:

3
0

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 14ms
memory: 3852kb

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:

1322
2697
1744
2612
4761
4998
2952
1327
881
5078
7815
4862
934
926
807
7274
7666
5327
3813
3227
4480
1577
2542
40
901
301
4352
3885
3815
5741
4613
1659
437
1416
3625
5259
565
119
2045
7618
9115
2048
3124
3685
2884
420
726
4009
179
3231
1444
1604
7130
3008
5958
8086
1539
3809
363
4478
3301
1741
819
2...

result:

wrong answer 2nd words differ - expected: '2696', found: '2697'

Subtask #4:

score: 0
Wrong Answer

Test #23:

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

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:

7254
2359
943
875
884
7681
707
5569
9263
1584
606
2099
2505
4050
5025
5005
5886
3043
2723
4456
1777
1963
4312
852
5010
2954
5460
1333
1702
785
6673
3074
470
2510
2057
7509
127
2897
3218
8860
8345
2015
1284
58
2450
4027
2254
4561
2182
1711
2085
1046
3998
6166
2358
1291
867
7451
5509
833
2817
568
6044...

result:

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