QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#80604 | #5173. 染色 | infinities | 0 | 15ms | 5908kb | C++14 | 2.9kb | 2023-02-24 14:14:30 | 2023-02-24 14:14:34 |
Judging History
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 = 5e5 + 7;
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], f[maxn];
signed main(){
n = read(), q = read();
for(fint i = 1; i <= n; i++)a[i] = read();
for(fint i = 2; i < n; i++){
if(a[i - 1] == a[i + 1] && a[i] != a[i - 1])a[i] = a[i - 1], f[i] = 1;
}
for(fint i = 2; i <= n; i++)if(a[i] != a[i - 1]){f[i] += 1;}
for(fint i = 1; i <= n; i++)f[i] += f[i - 1];
for(fint i = 1; i <= q; i++){
fint u = read(), v = read();
if(u > v)swap(u, v);
cout << v - u + f[v] - f[u] << "\n";
}
return 0;
}
}
signed main(){
return infinities::main();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 5436kb
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:
3787 4725 6171 8652 750 7242 190 7559 510 1177 261 2321 13654 6463 471 7755 2229 10828 1849 2756 4956 303 6195 646 6878 6382 11784 2801 3266 8093 18365 528 5669 18419 9880 6353 5155 15052 690 478 16120 13083 9161 8085 11342 6823 6608 5194 9398 8808 2246 10637 2775 12949 5123 2213 9093 1969 6684 2926...
result:
wrong answer 1st words differ - expected: '3668', found: '3787'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 15ms
memory: 5908kb
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:
115472 135785 56012 6606 9385 79867 95825 29778 39704 113819 67974 7358 67339 43650 45536 50286 11311 109879 73151 10934 4820 88920 47800 77338 27840 11148 12500 60713 19006 56212 11864 8020 5634 39503 68639 59488 17289 71532 71765 54741 52895 558 18849 122292 4104 44170 63777 34674 10073 25504 3387...
result:
wrong answer 1st words differ - expected: '113194', found: '115472'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 3ms
memory: 5564kb
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:
1351 2755 1778 2666 4860 5103 3017 1355 899 5176 7980 4961 955 943 823 7427 7822 5441 3892 3300 4571 1608 2590 40 922 308 4447 3966 3891 5853 4710 1691 445 1445 3699 5366 577 122 2087 7772 9304 2092 3186 3759 2945 429 741 4093 183 3298 1473 1636 7274 3069 6081 8249 1575 3885 370 4570 3365 1780 836 2...
result:
wrong answer 1st words differ - expected: '1322', found: '1351'
Subtask #4:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 9ms
memory: 5852kb
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:
2034 4401 434 1964 3514 1327 -3254 3883 1680 1760 1246 -286 6095 1752 3192 1284 958 2856 -2936 3043 7224 -2160 105 -2282 2045 3798 136 5175 2394 -899 -871 4791 1463 -2352 1951 -1229 485 -3225 5261 2905 202 450 1142 5185 2471 -2011 4329 2551 2115 560 -1337 -2267 713 -1024 1150 6668 4867 1148 952 -668...
result:
wrong answer 1st words differ - expected: '1263815', found: '2034'