QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#80647#5173. 染色infinities0 738ms95304kbC++143.2kb2023-02-24 15:32:502023-02-24 15:32:53

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 15:32:53]
  • 评测
  • 测评结果:0
  • 用时:738ms
  • 内存:95304kb
  • [2023-02-24 15:32:50]
  • 提交

answer

#include<bits/stdc++.h>
//#include <ext/pb_ds/hash_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
namespace infinities{
    #define fint register int
    #define ls(i) (i << 1)
    #define rs(i) ((i << 1) | 1)
    #define pii pair<int, int>
    #define im int mid = (l + r) >> 1
    #define INT __int128
    #define ll long long
    #define ui unsigned int
    #define lc ch[now][0]
    #define rc ch[now][1]
    const int mod = 998244353, INF = 998244353, maxn = (1 << 20) - 1;
    namespace FastIO{//10M
        const int SS = 1e7; char num_[50]; int cnt_;
        inline int xchar(){static char buf[SS]; static int len = 0, pos = 0; if(pos == len)pos = 0, len = fread(buf, 1, SS, stdin); if(pos == len)exit(0); return buf[pos++];}
        inline int read(){fint x = 0, f = 1, ch = getchar(); while(ch < '0' || ch > '9'){if(ch == '-')f = -1; ch = getchar();}while(ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar();} return x * f;}
        inline void write(int x){if(x == 0){putchar('0'); return;}if(x < 0)putchar('-'), x = -x; while(x)num_[++cnt_] = x % 10 ^ 48,x /= 10; while(cnt_)putchar(num_[cnt_--]);}
        inline void write(int x, char c){write(x), putchar(c);}
    }
    using namespace std;
    using namespace FastIO;
    namespace mystd{
        inline int qmin(int a, int b){return (a > b) ? b : a;} inline int qmax(int a, int b){return (a > b) ? a : b;}
        inline void chkmin(int &a, int b){a = min(a, b); return;} inline void chkmax(int &a, int b){a = max(a, b); return;}
        inline void qk(int &a, int b){a = a + b; a = (a >= mod) ? a - mod : a;}
        inline void sub(int &a, int b){a = a - b + mod; a = (a >= mod) ? a - mod : a;}
		inline int mul(int a, int b){return (1ll * a * b % mod + mod) % mod;}
        inline int qpow(int x, int k){fint res = 1; for(; k; k = (k >> 1), x = 1ll * x * x % mod)if(k & 1)res = 1ll * res * x % mod; return res;}
        inline void looked(int a[], int n){for(fint i = 1; i < n; i++)write(a[i], ' '); write(a[n], '\n');} inline void debug(){puts("qwq");} inline void YES(){puts("YES");} inline void Yes(){puts("Yes");} inline void yes(){puts("yes");} inline void NO(){puts("NO");} inline void No(){puts("No");} inline void no(){puts("no");}
    }
	using namespace mystd;
	//using namespace __gnu_pbds;
	//gp_hash_table<int, int>hsh;
    void file(){freopen("a.in", "r", stdin), freopen("a.out", "w", stdout);}
    int n, q, a[maxn], las[maxn], p[maxn], jump[20][maxn];
    signed main(){
    	n = read(), q = read();
    	p[0] = n + 1;
    	for(fint i = 1; i <= n; i++)a[i] = read(), p[i] = n + 1;
    	for(fint i = 1; i <= n; i++){
			if(las[a[i]] > 0)chkmin(p[las[a[i]] - 1], i);
			las[a[i]] = i;
		}
		for(fint i = n - 1; i >= 0; i--)chkmin(p[i], p[i + 1]);
		p[n + 1] = n + 1;
		for(fint i = 0; i <= n + 1; i++)jump[0][i] = p[i];
		for(fint i = 1; i < 20; i++)for(fint j = 0; j <= n + 1; j++)jump[i][j] = jump[i - 1][jump[i - 1][j]];
		while(q--){
			fint u = read(), v = read();
			if(u > v)swap(u, v);
			fint ans = (v - u) * 2;
			--u;
			for(fint i = 19; i >= 0; i--)if(jump[i][u] <= v)u = jump[i][u], ans -= (1 << i);
			cout << ans << "\n";
		}
        return 0;
    }
}
signed main(){
    return infinities::main();
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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:

3673
4594
5997
8409
730
7033
184
7346
495
1146
254
2260
13275
6279
457
7540
2168
10522
1799
2687
4821
294
6023
629
6678
6199
11452
2722
3172
7862
17849
512
5511
17904
9598
6168
5008
14633
671
466
15672
12715
8903
7860
11024
6624
6418
5040
9134
8559
2184
10334
2704
12583
4982
2153
8839
1913
6499
2844...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 34ms
memory: 91668kb

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:

127437
149759
61893
7276
10353
88154
105721
32845
43833
125648
75003
8151
74259
48170
50332
55498
12488
121293
80656
12011
5326
98147
52661
85276
30586
12331
13703
67056
20931
62091
13115
8834
6202
43574
75736
65629
19083
79004
79196
60486
58360
624
20829
134953
4518
48756
70364
38259
11129
28170
37...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #15:

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

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:

1323
2699
1746
2615
4765
5002
2954
1327
881
5081
7820
4865
936
926
809
7279
7671
5332
3816
3229
4483
1579
2542
40
901
301
4355
3887
3818
5744
4616
1660
438
1416
3628
5262
565
119
2046
7623
9121
2049
3126
3688
2886
420
727
4011
180
3234
1444
1604
7135
3011
5962
8091
1539
3812
363
4481
3303
1742
819
2...

result:

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

Subtask #4:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 738ms
memory: 95304kb

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:

1263867
308628
760159
79458
160359
576934
988266
1716183
1345178
215193
615986
546285
1385971
320728
1094322
52291
276170
227575
2476
147758
144811
667163
25418
223792
184331
1445290
1666388
547662
146413
969361
1106554
237565
817334
112496
84815
1188750
316711
717986
169539
559891
767825
412222
732...

result:

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