社区讨论
P8889求助 map做法30分!悬关
P8889[入门赛 #7] 狠狠地切割 (Hard Version)参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @lrvyjurx
- 此快照首次捕获于
- 2024/01/27 18:57 2 年前
- 此快照最后确认于
- 2024/01/27 20:40 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
int n,m,x,ans;
long long a[500002];
unordered_map<long long,bool>s;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=m;i++){
cin>>x;
s[x]=1;
}
bool f=0;
for(int i=1;i<=n;i++){
if(s.find(a[i])!=s.end())
f=0;
if(s.find(a[i])==s.end()&&!f){
ans++;
f=1;
}
}
cout<<ans;
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...