QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67895#5173. 染色lmeowdn0 32ms11996kbC++141.4kb2022-12-12 22:48:352022-12-12 22:48:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-12 22:48:37]
  • 评测
  • 测评结果:0
  • 用时:32ms
  • 内存:11996kb
  • [2022-12-12 22:48:35]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define bp __builtin_parity
#define y1 yyl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef bitset<509> bset;
typedef pair<bset,bset> v2;

int read() {
	int x=0,w=1; char c=getchar();
	while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
	while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
	return x*w;
}

const int N=1e6+9;
int n,m,q,a[N],b[N],nxt[N],lst[N],vst[N];

signed main() {
	n=read(), q=read();
	rep(i,1,n) a[i]=read(), m=max(m,a[i]);
	rep(i,1,q) {
		int l=read(), r=read();
		rep(i,1,n) b[i]=lst[i]=nxt[i]=0;
		if(l>r) {
			rep(i,r,l) b[i]=a[i];
			swap(l,r);
			reverse(b+l,b+r+1);
		} else {
			rep(i,l,r) b[i]=a[i];
		}
		int cnt=0;
		per(i,r,l) {
			nxt[i]=lst[b[i]];
			lst[b[i]]=i;
		}
		rep(i,l,r) {
			if(!nxt[i]) continue;
			else {
				rep(j,1,m) vst[i]=0;
				bool flag=1;
				rep(j,i+1,nxt[i]-1) {
					if(vst[b[j]]) {flag=0; break;}
					vst[b[j]]=0;
				}
				if(!flag) continue;
				rep(j,i+1,nxt[i]-1) cnt++, b[j]=b[i];
				i=nxt[i]-1;
			}
		}
		rep(i,l,r-1) if(b[i]!=b[i+1]) cnt++;
		printf("%lld\n",r-l+cnt);
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 11932kb

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:

3808
4751
6204
8693
755
7280
186
7591
505
1182
259
2328
13734
6493
468
7797
2228
10896
1857
2775
4982
300
6223
653
6910
6417
11837
2824
3276
8111
18440
527
5684
18488
9933
6385
5178
15109
692
477
16205
13146
9212
8116
11406
6854
6631
5204
9439
8848
2266
10684
2781
13017
5140
2231
9126
1967
6721
2937...

result:

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

Subtask #2:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

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:

128590
150559
62531
7374
10441
88815
106745
32878
44215
126808
75352
8164
74820
48640
50691
55991
12613
122048
81162
12039
5350
98845
53005
86137
30654
12441
13810
67599
21040
62712
13236
8880
6282
43893
76565
65927
19304
79691
80019
61040
58857
636
20937
136228
4563
49224
71110
38442
11202
28369
37...

result:


Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 32ms
memory: 11996kb

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:

1350
2747
1778
2666
4861
5100
3018
1354
898
5175
7982
4960
953
938
822
7434
7828
5448
3887
3304
4569
1606
2587
40
923
308
4453
3968
3890
5855
4716
1683
442
1447
3696
5365
575
121
2080
7779
9308
2094
3188
3756
2945
428
740
4095
182
3298
1470
1633
7270
3066
6083
8260
1577
3886
365
4562
3366
1777
833
2...

result:

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

Subtask #4:

score: 0
Time Limit Exceeded

Test #23:

score: 0
Time Limit Exceeded

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:


result: