QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#664242 | #1279. Distinct Number | ship2077 | WA | 79ms | 18252kb | C++23 | 1.2kb | 2024-10-21 19:48:49 | 2024-10-21 19:48:49 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int M=5005*60;
int n,m,x,ans,cnt[65];
vector<int>a[M],rec;
int read(){
int x=0;char ch=getchar();
while (!isdigit(ch)) ch=getchar();
while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
return x;
}
void insert(int y,int l){
a[++m].clear();
for (int i=60;i>=l;i--)
a[m].emplace_back((x&y)>>i&1);
}
int query(int x){return x<=60?1ll<<cnt[60-x]:1;};
void solve(){
n=read();x=read();m=0;
for (int i=0;i<=60;i++)
cnt[i]=(i?cnt[i-1]:0)+(x>>i&1);
for (int i=1;i<=n;i++){
int l=read(),r=read()+1,lg=31^__builtin_clz(l^r);
for (int j=0;j<lg;j++)
if (l>>j&1)
insert(l,j),l+=1ll<<j;
for (int j=lg;~j;j--)
if (~l>>j&1&&r>>j&1)
insert(l,j),l+=1ll<<j;
}
sort(a+1,a+m+1);ans=query(a[1].size());rec=a[1];
for (int i=2;i<=m;i++){
bool flag=rec.size()>a[i].size();
for (int j=0;!flag&&j<rec.size();j++)
if (a[i][j]&&!rec[j]) {flag=1;break;}
if (flag) ans+=query(a[i].size()),rec=a[i];
}
printf("%lld\n",ans);
}
signed main(){int T=read();while (T--) solve();return 0;}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3820kb
input:
3 2 1 1 2 343 34345 1 3 1 3 1 123242343 1 1000000000000000000
output:
2 3 32768
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 6ms
memory: 3888kb
input:
902 5 35 2 17 19 24 32 55 59 63 73 97 5 55 3 17 35 37 38 39 43 82 87 88 1 37 46 88 4 79 1 9 40 56 56 56 57 78 8 61 5 7 19 21 27 33 34 36 36 38 59 73 77 79 94 97 2 86 0 23 72 78 7 43 5 10 12 21 22 34 36 58 65 71 72 88 91 99 9 74 16 24 31 41 44 48 48 49 51 51 57 57 61 65 69 71 85 93 4 85 5 44 46 47 54...
output:
8 25 8 31 21 12 16 8 12 8 4 16 4 14 2 4 8 16 8 11 2 1 2 8 8 2 4 6 2 11 8 6 7 1 15 16 4 12 8 16 8 12 8 7 8 12 2 24 23 2 8 8 4 15 8 8 4 8 8 11 4 31 25 2 2 29 31 16 8 8 4 10 4 8 25 16 9 16 32 11 12 4 13 4 21 4 15 2 26 8 2 6 23 7 7 8 8 4 4 16 16 4 3 2 18 29 23 19 8 8 8 8 16 12 13 12 16 14 16 19 29 15 6 ...
result:
ok 902 tokens
Test #3:
score: 0
Accepted
time: 17ms
memory: 4144kb
input:
144 37 3097 273 289 377 483 493 527 881 1209 1210 1333 1521 1552 1554 1768 1967 2194 2218 2279 2567 2606 2614 2619 2976 3115 3388 3436 3684 3685 3885 3894 3963 4635 4793 4815 4979 5242 5292 5380 5495 5515 5569 5723 5815 5862 6114 6162 6253 6334 6394 6428 6638 6978 7063 7201 7416 7541 7703 7805 7884 ...
output:
32 62 248 238 111 256 126 960 128 235 112 64 8 64 256 1635 8 64 128 128 892 128 512 64 32 16 256 256 970 64 128 8 64 128 16 8 16 128 256 16 256 128 920 128 16 128 128 8 112 16 128 16 128 32 256 32 64 488 117 64 512 64 8 457 16 32 128 30 128 64 256 16 128 8 30 32 64 112 64 64 32 128 256 32 128 64 32 ...
result:
ok 144 tokens
Test #4:
score: 0
Accepted
time: 60ms
memory: 4932kb
input:
84 10 360403509 48973816 108252157 164366394 380884108 395265805 418262201 485100659 520738020 596118742 615507431 635305129 709062302 751555848 791261801 797493451 834840841 855972732 876160731 899012590 974871121 54 956256021 3167657 7951261 20481210 23841657 24030658 29152491 29609403 30268465 39...
output:
65536 521216 32768 8192 8192 32768 16384 61440 16384 131072 8192 61440 16384 32768 130048 65536 8192 129024 4096 32768 131072 524288 61120 4096 32768 16384 16384 8192 262144 131072 2023230 16384 65536 224776 262144 128 262144 30720 8192 16384 16384 32768 62920 2048 262144 8192 4096 4096 32768 65536 ...
result:
ok 84 tokens
Test #5:
score: -100
Wrong Answer
time: 79ms
memory: 18252kb
input:
12 642 656056144552294267 1205077504153600 1477360693520167 1595546284624450 4127356436235572 5414866662365273 5823146368992192 7337259496420109 7972682426389549 9448745794780636 11109842311460514 12887653433953860 13503449087275473 13781829500544374 14564496186927287 16027002617927709 1865702348720...
output:
60801024 199289818 1079552 13040096 4304768 128657707 7695072 51704064 5263912 67356600 529760 13776836
result:
wrong answer 1st words differ - expected: '2147483648', found: '60801024'