QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67902#5173. 染色lmeowdn0 101ms53488kbC++171.4kb2022-12-13 09:27:062022-12-13 09:27:07

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-13 09:27:07]
  • 评测
  • 测评结果:0
  • 用时:101ms
  • 内存:53488kb
  • [2022-12-13 09:27:06]
  • 提交

answer

#include<bits/stdc++.h>
#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,Q,a[N];

struct Jump {
	int t[21][N],a[N],cnt[N];
	void init(int *b) {
		rep(i,1,n) a[i]=b[i];
		int j=n; t[0][n+1]=n+1;
		per(i,n,1) {
			cnt[a[i]]++;
			if(cnt[a[i]]>1) {
				while(a[j]!=a[i]) j--;
				cnt[a[i]]--, t[0][i]=j, j--;
			} else t[0][i]=t[0][i+1];
		}
		rep(h,1,20) {
			rep(i,1,n) t[h][i]=t[h-1][t[h-1][i]];
		}
	}
	int qry(int l,int r) {
		int res=0;
		int u=l;
		per(h,20,0) if(t[h][u]&&t[h][u]<=r) u=t[h][u], res|=(1<<h);
		return res;
	}
} toright, toleft;

signed main() {
	n=read(), Q=read();
	rep(i,1,n) a[i]=read();
	toright.init(a);
	reverse(a+1,a+n+1);
	toleft.init(a);
	rep(i,1,Q) {
		int l=read(), r=read();
		if(l<=r) printf("%d\n",(r-l)*2-toright.qry(l,r));
		else printf("%d\n",(l-r)*2-toleft.qry(n-l+1,n-r+1));
	}
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 45844kb

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:

-2093327
-2092375
-2090917
-2088411
-2096391
-2089835
-2096959
-2089519
-2096637
-2095961
-2096887
-2094807
-2083359
-2090627
-2096677
-2089311
-2094903
-2086213
-2095283
-2094367
-2092141
-2096847
-2090897
-2096495
-2090205
-2090705
-2085251
-2094315
-2093853
-2088981
-2078609
-2096619
-2091429
-20...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 101ms
memory: 53488kb

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:

-1942987
-1916003
-2022237
-2088339
-2084633
-1990479
-1969251
-2057461
-2044103
-1945135
-2006429
-2087295
-2007343
-2038849
-2036239
-2029995
-2082045
-1950403
-1999587
-2082635
-2090707
-1978405
-2033455
-1993989
-2060171
-2082235
-2080589
-2015993
-2071823
-2022011
-2081281
-2086449
-2089661
-20...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #15:

score: 0
Wrong Answer
time: 3ms
memory: 37056kb

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:

-2095797
-2094389
-2095369
-2094479
-2092277
-2092035
-2094123
-2095791
-2096249
-2091963
-2089151
-2092179
-2096193
-2096207
-2096325
-2089705
-2089307
-2091693
-2093249
-2093841
-2092571
-2095539
-2094555
-2097111
-2096225
-2096841
-2092691
-2093175
-2093253
-2091283
-2092427
-2095457
-2096705
-20...

result:

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

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:

-826207
-1786799
-1332777
-2017245
-1935899
-1517029
-1103361
-371395
-744505
-1880747
-1477709
-1547841
-703439
-1774635
-996681
-2044571
-1819471
-1868291
-2094659
-1948567
-1951555
-1426289
-2071583
-1872115
-1911765
-643821
-421461
-1546421
-1949907
-1122385
-984441
-1858273
-1275253
-1984019
-2...

result: