QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#550471 | #8332. Two in One | dfghjjj | AC ✓ | 182ms | 11872kb | C++20 | 3.6kb | 2024-09-07 13:01:56 | 2024-09-07 13:01:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define re register
#define il inline
#define pii pair<int,int>
#define x first
#define y second
#define gc getchar()
#define rd read()
#define debug() puts("------------")
namespace yzqwq{
il int read(){
int x=0,f=1;char ch=gc;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=gc;}
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=gc;
return x*f;
}
il int qmi(int a,int b,int p){
int ans=1;
while(b){
if(b&1) ans=ans*a%p;
a=a*a%p,b>>=1;
}
return ans;
}
// il auto max(auto a,auto b){return (a>b?a:b);}
// il auto min(auto a,auto b){return (a<b?a:b);}
il int gcd(int a,int b){
if(!b) return a;
return gcd(b,a%b);
}
il int lcm(int a,int b){
return a/gcd(a,b)*b;
}
il void exgcd(int a,int b,int &x,int &y){
if(!b) return x=1,y=0,void(0);
exgcd(b,a%b,x,y);
int t=x;
x=y,y=t-a/b*x;
return ;
}
il int F(int n,int a,int b,int c){
//sum{|_ (ai+b)/c _| i:0~n}
if(!n) return b/c;
if(!a) return (n+1)*(b/c);
if(a>=c||b>=c){
int x=a/b,y=b/c;
return n*(n+1)/2*x+(n+1)*y+F(n,a%c,b%c,c);
}
int m=(a*n+b)/c;
return n*m+F(m-1,c,c-b+1,a);
}
struct lb{
int d[64];
il void print(){
for(re int i=0;i<63;++i)
if(d[i]) printf("%lld:%lld\n",i,d[i]);
return ;
}
lb(){memset(d,0,sizeof(d));}
il void operator +=(int x){
for(re int i=62;i>=0;--i){
if(!(x&(1ll<<i))) continue;
if(d[i]) x^=d[i];
else return d[i]=x,void(0);
}
return ;
}
int& operator [](int x){
return d[x];
}
il void operator +=(lb &x){
for(re int i=62;i>=0;--i)
if(x[i]) *this+=x[i];
return ;
}
il friend lb operator +(lb &x,lb &y){
lb z=x;
for(re int i=62;i>=0;--i)
if(y[i]) z+=y[i];
return z;
}
il int Max_calc(){
int ans=0;
for(re int i=62;i>=0;--i)
if((ans^d[i])>ans) ans^=d[i];
return ans;
}
};
mt19937 rnd(time(0));
}
using namespace yzqwq;
const int N=500000+10;
int n,a[N];
int cnt[N];
int b[N];
il bool cmp(int a,int b){
return cnt[a]>cnt[b];
}
il void solve(){
n=rd;
for(re int i=1;i<=n;++i) a[i]=rd,cnt[i]=0;
int Max=0;pii ans={0,0};
pii ans2={0,0};
int l=1;int idx=0;
for(re int r=l;r<=n;++r){
++cnt[a[r]];
if(Max<cnt[a[r]]){
Max=cnt[a[r]],ans={l,r},ans2={a[r],a[r]};
}
bool fl=0;
for(re int i=1;i<=idx;++i){
int w=(cnt[a[r]]|cnt[b[i]]);
fl|=(b[i]==a[r]);
if(w>Max){
Max=w,ans={l,r},ans2={a[r],b[i]};
}
}
if(!fl) b[++idx]=a[r];
sort(b+1,b+idx+1,cmp);
idx=min(idx,36*1ll);
// for(re int i=1;i<=n;++i){
// int w=(cnt[a[i]]|cnt[a[r]]);
// if(w>Max||(w==Max&&ans.x==1&&l==1)){
// Max=w;
// ans={l,r};
// ans2={i,a[r]};
// }
// }
}
cout<<Max<<"\n";
// cout<<ans.x<<" "<<ans.y<<"\n";
// cout<<ans2.x<<" "<<ans2.y<<"\n";
return ;
}
signed main(){
int t=rd;while(t--)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7864kb
input:
1 7 1 2 3 4 3 2 1
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 0ms
memory: 7860kb
input:
1 9 1 1 1 1 1 2 2 2 2
output:
7
result:
ok 1 number(s): "7"
Test #3:
score: 0
Accepted
time: 182ms
memory: 7772kb
input:
50 10000 72 65 90 94 67 93 41 43 54 83 31 34 38 37 44 42 92 63 66 79 90 45 41 40 19 54 34 90 13 74 40 77 41 57 74 86 91 79 34 39 21 88 90 57 23 31 8 15 80 27 45 38 53 96 51 82 70 71 19 75 62 95 31 67 99 97 94 29 90 7 95 82 61 98 62 77 43 65 66 30 41 69 38 79 51 9 63 77 13 30 72 70 67 93 92 45 74 50 ...
output:
255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
result:
ok 50 numbers
Test #4:
score: 0
Accepted
time: 15ms
memory: 7852kb
input:
79114 7 1 2 4 3 2 3 7 7 1 2 4 7 4 1 5 6 4 2 2 4 2 1 7 1 2 1 4 7 3 2 7 1 2 4 7 1 1 3 7 1 2 6 1 5 2 5 6 5 2 6 1 2 5 7 1 1 7 6 6 5 2 7 1 2 5 6 6 7 7 7 1 1 2 7 2 3 6 7 1 1 1 4 6 2 2 7 1 1 5 7 3 5 2 7 1 1 7 6 2 2 5 6 4 3 4 6 3 1 6 4 4 3 2 3 1 7 1 1 2 3 7 6 2 6 1 2 5 6 3 4 7 1 1 1 1 4 7 6 6 2 6 6 2 5 3 6 ...
output:
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 5 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 6 3 3 3 3 5 3 3 3 5 3 3 3 3 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 3 5 3 3 3 1 3 3 3 3 3 3 5 3 3 3 3 3 3 3 3 3 3 ...
result:
ok 79114 numbers
Test #5:
score: 0
Accepted
time: 17ms
memory: 7860kb
input:
50000 10 6 3 8 5 4 6 3 5 3 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7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 9 7 7 7 7 7 9 7 10 7 7 7 7 7 7 10 7 7 7 7 7 7 7 7 7 7 7 7 7 10 7 7 7 7 7 7 7 7 7 7 7 7...
result:
ok 50000 numbers
Test #7:
score: 0
Accepted
time: 130ms
memory: 7764kb
input:
5000 100 35 13 56 51 37 39 100 35 21 36 54 19 99 74 38 99 90 69 29 23 38 27 40 94 92 93 93 45 94 22 65 65 43 62 47 53 11 77 87 15 77 72 3 38 25 19 4 82 48 69 15 13 8 76 48 8 19 86 25 26 34 70 38 42 87 81 31 92 30 24 80 69 8 74 48 30 57 47 65 42 35 47 42 85 18 94 97 13 8 24 100 31 51 72 69 95 74 90 9...
output:
7 7 3 7 7 7 7 7 7 7 7 7 7 3 7 7 7 7 7 7 7 7 3 7 7 3 7 7 7 7 3 7 7 7 7 7 7 3 7 7 3 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 3 7 7 7 3 7 7 7 7 7 3 7 7 7 3 7 7 7 3 7 7 7 7 3 7 7 3 7 7 7 7 7 7 7 7 7 7 3 7 7 7 7 7 7 7 7 7 7 3 7 7 3 3 7 7 7 7 7 7 7 7 7 7 7 7 3 3 7 7 7 7 3 7 7 7 7 7 7 7 7 7 7 7 3 7 ...
result:
ok 5000 numbers
Test #8:
score: 0
Accepted
time: 18ms
memory: 7844kb
input:
5000 100 5 3 7 7 6 6 10 5 4 6 7 4 9 8 6 9 9 8 5 4 6 5 6 9 9 9 9 6 9 4 8 8 6 7 6 7 3 8 9 3 8 8 1 6 5 4 2 9 6 8 3 3 2 8 6 2 4 9 5 5 5 8 6 6 9 9 5 9 5 4 8 8 2 8 6 5 7 6 8 6 5 6 6 9 4 9 9 3 2 4 10 5 7 8 8 9 8 9 9 8 100 6 6 4 2 6 5 9 9 6 7 9 7 6 6 3 3 4 9 7 7 9 6 9 3 6 3 10 6 8 9 8 9 5 6 3 3 5 9 8 8 8 1 ...
output:
31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 ...
result:
ok 5000 numbers
Test #9:
score: 0
Accepted
time: 147ms
memory: 7920kb
input:
500 1000 826 799 36 103 143 218 173 682 364 907 788 338 489 308 749 437 185 166 973 723 463 220 892 883 126 274 442 324 227 772 349 202 740 43 361 521 690 113 160 281 364 507 913 552 766 661 82 931 590 896 439 701 330 538 939 710 841 660 620 727 309 506 113 55 230 459 734 675 977 737 922 642 860 894...
output:
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...
result:
ok 500 numbers
Test #10:
score: 0
Accepted
time: 95ms
memory: 7724kb
input:
500 1000 28 28 6 10 11 14 13 26 19 30 28 18 22 17 27 20 13 12 31 26 21 14 29 29 11 16 21 18 15 27 18 14 27 6 19 22 26 10 12 16 19 22 30 23 27 25 9 30 24 29 20 26 18 23 30 26 29 25 24 26 17 22 10 7 15 21 27 25 31 27 30 25 29 29 25 24 9 10 16 24 29 23 19 16 28 21 28 12 31 10 20 18 11 21 14 11 14 12 19...
output:
63 63 127 127 63 127 125 63 127 127 127 126 127 63 63 63 127 127 127 127 63 127 126 127 127 127 127 127 127 63 127 127 127 63 127 127 123 127 63 127 63 119 127 63 125 127 127 63 127 127 123 126 127 127 63 127 125 127 127 119 127 127 119 127 127 63 63 127 63 63 127 127 127 63 122 63 127 127 127 63 63...
result:
ok 500 numbers
Test #11:
score: 0
Accepted
time: 141ms
memory: 7844kb
input:
50 10000 5231 4283 8159 8842 4592 8761 1749 1922 2947 6985 988 1176 1520 1420 2002 1812 8626 4019 4403 6360 8219 2027 1745 1619 395 2982 1182 8185 179 5604 1659 5959 1682 3355 5489 7484 8447 6328 1184 1555 477 7889 8272 3343 544 975 80 226 6518 729 2044 1450 2904 9281 2622 6742 4921 5143 372 5695 39...
output:
7 7 7 7 7 7 7 7 7 7 7 7 15 7 15 7 7 7 7 7 7 7 7 7 7 7 15 7 15 7 7 7 7 7 7 15 7 7 7 7 15 7 15 7 7 7 7 7 7 15
result:
ok 50 numbers
Test #12:
score: 0
Accepted
time: 140ms
memory: 7776kb
input:
5 100000 91675 46565 38979 3941 53894 98418 84900 84804 53487 7391 37558 42152 21892 48134 40091 35126 70005 1153 61201 47390 57436 20581 76773 48574 35571 42660 42943 41736 20593 53925 22043 8372 31184 39982 17663 22303 48407 27491 22257 13831 393 13278 29991 80618 89887 63441 66588 3667 95209 5383...
output:
7 15 7 15 15
result:
ok 5 number(s): "7 15 7 15 15"
Test #13:
score: 0
Accepted
time: 169ms
memory: 7920kb
input:
5 100000 302 215 197 62 232 313 291 291 231 85 193 205 147 219 200 187 264 33 247 217 239 143 277 220 188 206 207 204 143 232 148 91 176 199 132 149 220 165 149 117 19 115 173 283 299 251 258 60 308 232 146 306 197 294 154 246 245 305 134 237 129 217 233 192 65 210 290 153 309 212 229 155 157 33 260...
output:
1023 1023 1023 1023 1023
result:
ok 5 number(s): "1023 1023 1023 1023 1023"
Test #14:
score: 0
Accepted
time: 12ms
memory: 11872kb
input:
5 99999 5 5 5 5 5 5 4 5 4 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 4 5 5 5 5 4 5 5 3 5 5 5 5 5 5 5 5 3 5 5 4 5 5 5 3 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 4 5 5 5 5 5 5 5 5 4 4 5 5 5 5 5 5 5 5 5 ...
output:
98303 98303 98303 98303 98303
result:
ok 5 number(s): "98303 98303 98303 98303 98303"
Test #15:
score: 0
Accepted
time: 139ms
memory: 9780kb
input:
5 99999 63915 63915 63915 63915 38059 63915 63915 63915 25192 63915 1024 63915 63915 63915 63915 63915 63915 63915 63915 63896 63915 63915 14963 63915 63915 63915 52208 84889 63915 63915 63915 63915 63915 40674 63915 62258 63915 63915 63915 16744 63915 63915 63915 96429 91077 63915 63915 63915 43576...
output:
65535 83967 65535 98303 57343
result:
ok 5 number(s): "65535 83967 65535 98303 57343"
Test #16:
score: 0
Accepted
time: 109ms
memory: 7904kb
input:
500 999 324 675 675 324 675 675 675 675 675 324 675 324 675 324 324 675 324 675 675 675 324 675 324 675 324 675 324 675 324 675 675 324 675 675 675 675 675 324 675 324 675 675 675 675 324 324 675 675 324 324 675 675 324 675 675 675 324 675 324 675 675 675 675 675 675 675 675 675 675 675 675 324 675 ...
output:
999 551 287 639 767 735 511 511 511 783 511 639 703 991 895 879 511 511 511 415 471 503 959 511 511 831 383 511 767 511 103 895 990 767 759 255 767 639 469 959 511 447 703 511 511 895 959 511 959 703 255 879 815 767 975 991 895 983 983 767 987 255 767 511 703 511 860 927 735 511 831 991 767 855 127 ...
result:
ok 500 numbers
Test #17:
score: 0
Accepted
time: 134ms
memory: 7768kb
input:
50 10000 3548 5617 5617 3548 3548 1832 5617 5617 5617 3548 5617 5617 3548 5617 4445 3548 3548 3548 3548 5617 3548 5617 5617 5617 3548 3548 3548 5617 3548 5617 5617 3548 3548 5617 4470 3548 3548 5617 5617 5617 5617 5617 3548 5617 5617 3339 5617 3548 3548 6761 3548 3548 5617 3548 5617 5617 3548 3548 3...
output:
8191 4095 9343 9711 6143 6143 8191 6143 9939 5631 7487 8191 9215 9215 9215 8191 8191 8191 1535 8191 7679 7167 6142 8188 2047 9855 9215 6143 7999 9654 4095 7791 9263 6143 9215 5375 8382 9215 4095 7623 8191 8191 6143 3327 8063 7167 7167 4095 8191 8191
result:
ok 50 numbers
Test #18:
score: 0
Accepted
time: 39ms
memory: 7772kb
input:
500 999 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 675 ...
output:
999 551 287 639 767 735 511 511 511 783 511 639 703 991 895 879 511 511 511 415 471 503 959 511 511 831 383 511 767 511 103 895 990 767 759 255 767 639 469 959 511 447 703 511 511 895 959 511 959 703 255 879 815 767 975 991 895 983 983 767 987 255 767 511 703 511 860 927 735 511 831 991 767 855 127 ...
result:
ok 500 numbers
Extra Test:
score: 0
Extra Test Passed