QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834012 | #9907. 最大匹配 2 | zhenjianuo2025 | 0 | 25ms | 17776kb | C++20 | 2.5kb | 2024-12-27 09:57:19 | 2024-12-27 09:57:21 |
Judging History
answer
#include<bits/stdc++.h>
bool Mbg;
using namespace std;
// __int128 abs(__int128 x){return max(x,-x);}
istream&operator>>(istream&cin,__int128 &x){
char c;bool f=0;
while(((c=cin.get())<'0'||c>'9')&&c!='-');
if(c=='-'){f=1;c=cin.get();}x=c-'0';
while((c=cin.get())>='0'&&c<='9')x=x*10+c-'0';
if(f)x=-x;return cin;
}
ostream&operator<<(ostream&cout,__int128 x){
if(x<0){cout.put('-');x=-x;}
if(x>9)return (cout<<(x/10)).put(x%10+'0');return cout.put(x%10+'0');
}
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define int long long
#define inf (long long)(1e9)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
const int mod=998244353;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
void Dec(int &x,int y){x=x>=y?x-y:x-y+mod;}
int fpm(int x,int y){
int ans=1;for(;y;y>>=1,(x*=x)%=mod)if(y&1)(ans*=x)%=mod;return ans;
}
int n,m,a[200010],b[200010],mch[200010];
set<int> st[200010];
void work(){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>b[i];
int ans=0;
for(int i=1;i<=n;i++){
if(b[i]){
if(!st[a[i]].empty()){
++ans;
mch[i]=mch[*st[a[i]].begin()]=1;
st[a[i]].era(st[a[i]].begin());
}
}else{
st[a[i]].ins(i);
}
}
int cnt=0;
for(int i=1;i<=n;i++){
exc(mch[i]);
if(!b[i]){
++cnt;
}else if(cnt){
--cnt;++ans;
}
}
cout<<ans<<'\n';
}
bool Med;
signed main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int T=1;while(T--)work();
// cerr<<"Time: "<<clock()<<" ms;\n";
// cerr<<"Memory: "<<abs(&Med-&Mbg)/1024.0/1024.0<<" MiB.\n";
}
/*
- CONTINUE, NON-STOPPING, FOR THE FAITH
- START TYPING IF YOU DON'T KNOW WHAT TO DO
- STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 16276kb
input:
100 0 1 1 2 1 2 2 2 2 2 1 2 1 1 2 2 1 2 2 2 2 2 1 1 2 2 2 1 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 1 1 2 1 2 1 1 1 2 2 2 2 2 2 1 1 1 2 1 1 1 1 1 2 2 1 1 2 1 1 2 1 1 2 2 2 1 2 2 2 1 2 1 2 1 2 1 1 2 1 1 2 1 1 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 1 0 0 0 0 1 1 1 1 1 ...
output:
42
result:
wrong answer 1st words differ - expected: '45', found: '42'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 16684kb
input:
2000 0 2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 2 2 2 1 1 1 1 1 1 2 1 1 2 2 1 2 1 2 2 2 1 1 2 1 1 1 2 2 2 2 2 2 1 1 2 1 1 2 2 1 2 1 1 1 1 2 1 1 1 1 1 2 2 2 2 1 2 2 1 2 2 2 2 2 1 2 1 2 1 1 2 1 1 2 2 1 1 1 1 1 1 1 1 2 2 1 2 2 2 2 2 1 1 2 2 2 2 1 2 2 2 1 1 1 2 1 2 1 1 1 2 2 1 2 1 1 1...
output:
937
result:
wrong answer 1st words differ - expected: '954', found: '937'
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 24ms
memory: 17776kb
input:
200000 0 1 2 2 2 2 2 2 1 1 2 2 1 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 2 2 2 2 1 2 2 1 2 1 1 2 2 2 2 1 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 2 2 1 1 2 1 1 1 2 2 2 2 1 1 2 2 1 1 2 1 2 2 2 2 2 1 1 2 2 2 2 1 2 1 2 2 2 1 2 2 2 2 1 2 2 2 1 1 1 2 2 1 2 2 2 1 1 1 1 1 2 1 2 1 2 1 2 1 2 1 2 2 1 2 2 2 1 1 1 2 1 2 1 1 1...
output:
99466
result:
wrong answer 1st words differ - expected: '99478', found: '99466'
Subtask #4:
score: 0
Wrong Answer
Test #61:
score: 0
Wrong Answer
time: 24ms
memory: 17720kb
input:
200000 200000 1 2 1 2 2 1 2 1 2 1 1 2 1 1 2 1 1 2 1 2 2 1 2 2 2 1 2 2 2 2 2 1 2 1 2 1 1 2 1 1 2 2 2 1 1 2 2 1 2 1 2 1 1 2 1 2 2 2 1 2 1 2 1 1 1 1 2 1 1 1 1 1 1 1 2 2 2 2 2 2 2 1 1 2 2 1 2 2 2 2 2 1 1 1 2 2 2 1 1 1 1 1 1 1 2 2 1 2 2 1 1 1 1 1 2 2 2 2 2 2 1 1 2 2 2 1 2 2 2 2 1 1 1 2 2 1 2 2 2 1 1 1 2 ...
output:
99553
result:
wrong answer 1st words differ - expected: '99575', found: '99553'
Subtask #5:
score: 0
Wrong Answer
Test #71:
score: 0
Wrong Answer
time: 14ms
memory: 16860kb
input:
100000 100000 2 1 1 1 1 1 1 2 2 2 2 1 2 1 1 1 2 2 1 2 1 2 2 2 2 2 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 2 1 2 2 2 2 1 2 1 1 1 2 2 2 1 1 2 1 1 1 2 1 2 2 2 1 1 2 1 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 2 1 2 1 2 2 2 2 2 2 2 1 1 1 1 2 1 2 1 1 1 1 2 2 2 1 2 1 1 1 2 2 2 1 1 2 1 2 2 2 2 2 1 1 2 1 1 1 1 ...
output:
49745
result:
wrong answer 1st words differ - expected: '49860', found: '49745'
Subtask #6:
score: 0
Wrong Answer
Test #101:
score: 0
Wrong Answer
time: 25ms
memory: 17620kb
input:
200000 200000 1 2 1 1 2 1 1 1 2 1 2 2 2 1 2 1 1 2 2 2 1 2 2 2 2 1 2 1 1 1 1 2 1 2 2 1 2 2 2 2 1 1 1 2 1 1 1 2 2 1 1 1 2 1 1 2 1 1 2 2 1 1 2 2 2 1 1 1 1 1 1 2 1 1 2 1 2 2 1 2 2 2 1 2 2 1 2 2 1 1 1 1 1 2 2 2 1 1 2 2 1 1 1 2 2 1 1 2 2 2 2 2 2 1 2 1 1 2 2 2 1 1 1 2 1 2 1 1 1 1 1 2 1 1 2 2 1 1 2 2 1 2 1 ...
output:
99340
result:
wrong answer 1st words differ - expected: '99491', found: '99340'