QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#668428 | #7311. Welcome to ICPCCamp 2017 | Afterlife# | WA | 31ms | 14520kb | C++20 | 1.5kb | 2024-10-23 14:21:51 | 2024-10-23 14:22:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=200020;
int n,m;
int p[N],a[N];
set<int> S[N];
int pw2[N];
void init(int n){
pw2[0]=1;
for(int i=1;i<=n;++i){
pw2[i]=(pw2[i-1]<<1)%mod;
}
}
struct BIT{
int b[N];
inline int lowbit(int x){
return x&(-x);
}
void clear(int n){
for(int i=1;i<=n;++i)b[i]=0;
}
inline int Ask(int x){
int ans=0;
while(x){
ans+=b[x];
x-=lowbit(x);
}
return ans;
}
inline void Add(int x,int d){
while(x<=m){
b[x]+=d;
x+=lowbit(x);
}
}
}B;
void Solve(){
B.clear(m);
for(int i=1;i<=m;++i){
p[i]=0;
S[i].clear();
}
for(int i=1;i<=n;++i){
int k;
cin>>k;
for(int j=1;j<=k;++j){
int x;
cin>>x;
S[j].insert(x);
}
}
for(int i=1;i<=m;++i){
for(auto x:S[i]){
if(!p[x]){
p[x]=i;
B.Add(i,1);
}
}
}
for(int i=1;i<=m;++i){
cin>>a[i];
}
int ans=1;
for(int i=1;i<=m;++i){
int t=m;
if(p[a[i]])B.Add(t=p[a[i]],-1);
ans=(ans+pw2[B.Ask(t)])%mod;
}
cout<<ans<<'\n';
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
init(200000);
while(cin>>n>>m)Solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 13936kb
input:
2 3 2 1 3 3 2 1 3 2 1 3 0 3 1 2 3
output:
5 4
result:
ok 2 number(s): "5 4"
Test #2:
score: -100
Wrong Answer
time: 31ms
memory: 14520kb
input:
3 16 1 7 1 16 1 4 14 10 8 1 4 13 5 9 7 12 2 6 3 16 11 15 10 16 2 10 6 2 12 1 3 16 4 1 2 11 5 1 14 1 9 4 14 10 4 13 2 7 14 1 15 1 14 6 15 12 9 5 14 10 16 4 7 11 2 3 8 1 13 6 15 2 15 5 2 10 13 1 11 2 6 10 3 4 9 12 3 13 1 10 7 3 4 1 10 12 13 6 9 14 15 11 5 2 8 5 6 1 6 1 6 1 4 5 4 5 1 2 3 3 4 6 3 3 5 4 ...
output:
62 2454 2323 27 17 3764897 46 322 91469 2261 37 192 2 4 32 105 19 7227 345 37 849 25 4 71 32 2 4 24 63 13 2 53 4 97 27 70 2 24 87 32 23 48 10 26 31 45815 39 5 26 17 106 94 53 18 129 6 76 1748 64 747 74 7 64 95 187 88 7 16 246 4 14 13 68 23 424 16 8 592 1068008 116 4 2 119 4 285 13 8 128 175 33 59 11...
result:
wrong answer 2nd numbers differ - expected: '570', found: '2454'