QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#840034 | #9725. Lottery | jiangzhihui | WA | 1ms | 3596kb | C++14 | 1.6kb | 2025-01-02 14:40:28 | 2025-01-02 14:40:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
void solve(int idx){
map<int,int> mp;
int n;
cin>>n;
for(int i=1;i<=n;i++){
int a,x;
cin>>a>>x;
mp[a]+=x;
}
for(auto it=mp.begin();it!=mp.end();it++){
int a=it->first;
int x=it->second;
mp[a]=0;
for(int j=0;(1<<j)<=x;j++){
if(x>=(1<<j)){
mp[a+j]++;
x-=(1<<j);
}
}
if(x>0){
for(int j=0;(1<<j)<=x;j++){
if((x>>j)&1){
mp[a+j]++;
x-=(1<<j);
}
}
}
}
vector<pair<int,int>> b;
b.push_back(make_pair(-5,0));
int cnt=0;
for(auto v:mp){
b.push_back(v);
cnt++;
}
vector<vector<int>> dp(b.size(),vector<int>(2,0));
dp[0][0]=1;
for(int i=1;i<=cnt;i++){
if(b[i].first==b[i-1].first+1){
dp[i][0]=dp[i-1][0]*2%mod;
dp[i][1]=dp[i-1][1]*b[i].second;
if(b[i].second==2){
dp[i][1]=(dp[i][1]+dp[i-1][0])%mod;
}
}else{
dp[i][0]=1ll*(dp[i-1][0]+dp[i-1][1])%mod*2%mod;
if(b[i].second==2){
dp[i][1]=(dp[i-1][0]+dp[i-1][1])%mod;
}
}
}
cout<<"Case #"<<idx<<": "<<(dp[cnt][0]+dp[cnt][1])%mod<<'\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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3524kb
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: 1ms
memory: 3596kb
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: 880 Case #2: 30491019 Case #3: 104055295 Case #4: 334447574 Case #5: 408559280 Case #6: 882941952 Case #7: 361148627 Case #8: 176201356 Case #9: -349699476 Case #10: -488803333 Case #11: 813936640 Case #12: 62020087 Case #13: 98828288 Case #14: 80484715 Case #15: 56351312 Case #16: 54251765...
result:
wrong answer 1st lines differ - expected: 'Case #1: 630', found: 'Case #1: 880'