QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#839945#9725. LotteryjiangzhihuiWA 2ms8168kbC++141.4kb2025-01-02 12:16:032025-01-02 12:16:07

Judging History

This is the latest submission verdict.

  • [2025-01-02 12:16:07]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 8168kb
  • [2025-01-02 12:16:03]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;
struct node{
    int p,x;
    bool operator < (const node& o)const{
        return p<o.p;
    }
};
node a[N];
int n;
multiset<int> b[N];
void solve(int idx){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i].p>>a[i].x;
        b[i].clear();
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=a[i].x;j<<=1){
            b[i].insert(j);
            a[i].x-=j;
        }
        if(a[i].x>0)b[i].insert(a[i].x);
        if(i==n)break;
        vector<int> tmp;
        for(auto v:b[i]){
            int T=v;
            int cnt=0;
            while(T%2==0){
                cnt++;
                T/=2;
            }
            if(cnt+a[i].p>=a[i+1].p){
                int d=cnt+a[i].p-a[i+1].p;
                while(d--)T*=2;
                b[i+1].insert(T);
                tmp.push_back(v);
            }
        }
        for(auto v:tmp){
            b[i].erase(b[i].find(v));
        }
    }
    int ans=1;
    for(int i=1;i<=n;i++){
        ans=1ll*ans*(b[i].size()+1)%mod;
    }
    cout<<"Case #"<<idx<<": "<<ans<<'\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    int idx=1;
    while(T--){
        solve(idx++);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 8148kb

input:

2
3
1 1
2 1
3 1
3
1 1
2 2
3 3

output:

Case #1: 8
Case #2: 18

result:

ok 2 lines

Test #2:

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

input:

100
3
14 14
9 12
8 17
3
26 3066725
19 3460487
8 2992323
3
1 13014079
7 11948973
26 4846920
3
9 17117727
7 12599223
1 3986051
3
15 7310145
10 33800431
4 23981598
3
12 6041740
6 48783713
9 49166903
3
6 23123493
13 41855136
3 18453412
3
22 31889237
26 60412072
12 25347349
3
18 47343610
6 15422850
15 25...

output:

Case #1: 90
Case #2: 8320
Case #3: 7644
Case #4: 2440
Case #5: 5472
Case #6: 2310
Case #7: 4640
Case #8: 6840
Case #9: 5192
Case #10: 9408
Case #11: 2208
Case #12: 7200
Case #13: 3024
Case #14: 8568
Case #15: 3894
Case #16: 3162
Case #17: 2814
Case #18: 8700
Case #19: 2592
Case #20: 8850
Case #21: 1...

result:

wrong answer 1st lines differ - expected: 'Case #1: 630', found: 'Case #1: 90'