QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#743113 | #5173. 染色 | leihonglongyin | 0 | 205ms | 91812kb | C++20 | 1.3kb | 2024-11-13 18:16:58 | 2024-11-13 18:16:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;const int N=1e6+5;int n,q,vi[N],fa[N],f[N],ans[N];vector<int>v[N];vector<pair<int,int>>s[N];
#define gc() (iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,SIZE,stdin),(iS==iT?EOF:*iS++)):*iS++)
namespace IO{const int SIZE=(1<<21)+1;char ibuf[SIZE],*iS,*iT,obuf[SIZE],*oS=obuf,*oT=oS+SIZE-1,c,qu[55];int f,qr;
inline void flush(){fwrite(obuf,1,oS-obuf,stdout),oS=obuf,fflush(stdout);}inline void putc(char x){*oS++=x;if(oS==oT)flush();}
template<class I>inline void read(I &x){for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;}
template<class I>inline void print(I x){if(!x)putc('0');if(x<0)putc('-'),x=-x;while(x)qu[++qr]=x%10+'0',x/=10;while(qr)putc(qu[qr --]);}
struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
}using IO::read;using IO::putc;using IO::print;
void cal(int u){if(fa[u]==u)return;f[u]+=f[fa[u]],fa[u]=fa[fa[u]];}
int main(){//freopen("color.in","r",stdin),freopen("color.out","w",stdout);
read(n),read(q);for(int x,lst=0,i=1;i<=n;i++)read(x),lst=max(lst,vi[x]),v[lst].push_back(i),vi[x]=i;
for(int x,y,i=1;i<=q;i++){read(x),read(y);if(x>y)swap(x,y);s[x].push_back({y,i});}
for(int i=n;i;i--){fa[i]=i;for(auto j:v[i])f[j]=1,fa[j]=i;
for(auto j:s[i])cal(j.first),ans[j.second]=2*(j.first-i)-f[j.first];
}for(int i=1;i<=q;i++)print(ans[i]),putc('\n');
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 10228kb
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:
3822 4774 6232 8738 758 7314 190 7630 512 1188 262 2342 13790 6522 472 7838 2246 10936 1866 2782 5008 302 6252 654 6944 6444 11898 2834 3296 8168 18540 530 5720 18596 9978 6412 5206 15206 694 482 16284 13214 9254 8164 11454 6890 6672 5238 9494 8892 2272 10738 2804 13080 5168 2238 9178 1984 6748 2954...
result:
wrong answer 1st words differ - expected: '3668', found: '3822'
Subtask #2:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 17ms
memory: 22328kb
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:
154158 181134 74906 8810 12516 106663 127888 39687 53046 152008 90716 9853 89798 58298 60909 67153 15104 146744 97560 14514 6442 118736 63694 103153 36975 14913 16560 81154 25325 75137 15868 10699 7488 52670 91624 79372 23074 95627 95791 73178 70583 752 25200 163232 5454 58951 85105 46282 13446 3408...
result:
wrong answer 1st words differ - expected: '113194', found: '154158'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 3ms
memory: 8268kb
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:
1352 2758 1778 2670 4864 5108 3023 1356 900 5182 7992 4962 956 942 824 7440 7841 5456 3897 3308 4578 1609 2593 40 923 308 4458 3973 3895 5851 4722 1692 444 1448 3703 5368 578 120 2088 7781 9324 2095 3189 3763 2951 430 740 4102 182 3303 1472 1635 7288 3072 6093 8264 1578 3889 368 4567 3371 1782 834 2...
result:
wrong answer 1st words differ - expected: '1322', found: '1352'
Subtask #4:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 205ms
memory: 91812kb
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:
1270942 310350 764371 79904 161250 580120 993780 1725746 1352644 216400 619440 549306 1393706 322514 1100461 52578 277677 228857 2490 148581 145594 670859 25566 225034 185384 1453313 1675681 550726 147240 974764 1112706 238876 821894 113130 85288 1195391 318455 722013 170480 562983 772111 414542 736...
result:
wrong answer 1st words differ - expected: '1263815', found: '1270942'