QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#509624#1436. Split in Setsc20230201WA 0ms3780kbC++141.4kb2024-08-08 16:35:332024-08-08 16:35:33

Judging History

你现在查看的是最新测评结果

  • [2024-08-08 16:35:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3780kb
  • [2024-08-08 16:35:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll maxn=1e5+5, mo=1e9+7;

ll a[maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    ll n,k; cin>>n>>k;
    for(ll i=1;i<=n;i++) cin>>a[i];
    ll ans=1, val=0;
    for(ll i=29;i>=0;i--) {
        ll cnt=0;
        vector<ll> vec;
        for(ll j=1;j<=n;j++) {
            if((a[j]>>i)&1) cnt++;
            else vec.push_back(a[j]);
        }
        if(cnt<k) {
            for(ll j=1;j<=n;j++) if((a[j]>>i)&1) val+= a[j]&((1<<i+1)-1);
            for(ll j=k;j>k-cnt;j--) ans=ans*j%mo;
            n-=cnt, k-= cnt;
            for(ll j=1;j<=n-cnt;j++) a[j]=vec[j-1];
        }else {
            if(vec.size()==0) {
                if(cnt>k) val+= k*(1<<i);
                else {
                    for(ll j=1;j<=k;j++) val+= a[j]&((1<<i+1)-1);
                    for(ll j=k;j>=1;j--) ans=ans*j%mo;
                    break;
                }
            }else {
                ll x=vec[0];
                for(ll j=1;j<vec.size();j++) x&=vec[j];
                vec.clear();
                for(ll j=1;j<=n;j++) if((a[j]>>i)&1) vec.push_back(a[j]);
                vec.push_back(x);
                n=vec.size();
                for(ll j=1;j<=n;j++) a[j]=vec[j-1];
                val+= (k-1)*(1<<i);
            }
        }
    }
    cout<<val<<' '<<ans<<'\n';
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3780kb

input:

3 2
4 7 5

output:

11 2

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

4 1
44 47 74 77

output:

8 1

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

4 4
44 47 74 77

output:

242 24

result:

ok 2 tokens

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3556kb

input:

1000 975
633065 7087 25267 3940676 618039 1695 2043 728466935 3498 13604984 4 99 119488 151315 12 32 52705062 26815 1902279 33952 480604 390647001 60 1 12566875 7591859 6 119892 7829822 2129 4 11644639 17 33200 5330 338 2 9 6862 3781 148087 57 198 13224999 10493180 1 5755424 216 1757297 210 1002623 ...

output:

35119198987 373564662

result:

wrong answer 1st words differ - expected: '35467198613', found: '35119198987'