QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#834023 | #9907. 最大匹配 2 | zhenjianuo2025 | 0 | 49ms | 142692kb | C++20 | 2.8kb | 2024-12-27 10:08:54 | 2024-12-27 10:08:58 |
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];
queue<int> st[200010];
int sol(){
for(int i=1;i<=n;i++){
mch[i]=0;
while(!st[i].empty()){
st[i].pop();
}
}
int ans=0;
for(int i=n;i;i--){
if(!b[i]){
if(!st[a[i]].empty()){
++ans;
mch[i]=mch[st[a[i]].front()]=1;
st[a[i]].pop();
}
}else{
st[a[i]].push(i);
}
}
int cnt=0;
for(int i=1;i<=n;i++){
exc(mch[i]);
if(!b[i]){
++cnt;
}else if(cnt){
--cnt;++ans;
}
}
return ans;
}
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];
cout<<sol()<<'\n';
for(int i=1,x,y,z;i<=m;i++){
cin>>x>>y>>z;
a[x]=y;
b[x]=z;
cout<<sol()<<'\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
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 15ms
memory: 142108kb
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:
44
result:
wrong answer 1st words differ - expected: '45', found: '44'
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 20ms
memory: 141940kb
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:
939
result:
wrong answer 1st words differ - expected: '954', found: '939'
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 49ms
memory: 142692kb
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
Time Limit Exceeded
Test #61:
score: 0
Time Limit Exceeded
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 99553 99552 99553 99554 99555 99555 99556 99557 99557 99557 99557 99556 99555 99555 99555 99556 99556 99555 99556 99556 99555 99556 99555 99556 99557 99557 99558 99557 99558 99559 99559 99559 99558 99558 99557 99558 99558 99558 99558 99559 99559 99558 99559 99559 99559 99559 99558 99557 99557 ...
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #71:
score: 0
Time Limit Exceeded
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 49744 49744 49744 49745 49745 49745 49745 49745 49746 49746 49746 49746 49745 49744 49744 49743 49743 49743 49742 49741 49741 49741 49741 49740 49740 49741 49741 49740 49740 49739 49738 49737 49736 49736 49736 49736 49737 49737 49737 49737 49736 49735 49734 49734 49734 49734 49734 49734 49734 ...
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #101:
score: 0
Time Limit Exceeded
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 99340 99341 99340 99341 99340 99340 99339 99339 99339 99339 99339 99340 99339 99339 99338 99338 99338 99339 99339 99340 99340 99340 99339 99339 99339 99338 99338 99338 99338 99338 99337 99338 99338 99338 99337 99336 99336 99337 99336 99337 99337 99336 99336 99337 99337 99336 99335 99335 99335 ...