QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#834020#9907. 最大匹配 2 zhenjianuo20250 21ms17752kbC++202.7kb2024-12-27 10:05:132024-12-27 10:05:15

Judging History

你现在查看的是最新测评结果

  • [2024-12-27 10:05:15]
  • 评测
  • 测评结果:0
  • 用时:21ms
  • 内存:17752kb
  • [2024-12-27 10:05:13]
  • 提交

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];

int sol(){
    for(int i=1;i<=n;i++){
        mch[i]=0;
        st[i].clear();
    }
    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;
        }
    }
    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
*/

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 16992kb

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: 4ms
memory: 16308kb

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: 21ms
memory: 17752kb

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:


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:


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:


result: