E:双泊对照

补题链接🔗:https://cpc.csgrandeur.cn/csgoj/problemset/problem?pid=1587

多进程,按照题目一步步写就行

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fi first
#define se second
const ll N=5005,mod=92084931,INF=1e18;
void solve(int role){
    ll n;
    if(role == 0){
        cin>>n;
        vector<ll> a(n);
        for(ll i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        cout<<n<<endl;
        for(ll i=0;i<n;i++)cout<<a[i]<<" ";
        cout<<endl;
        cout.flush();
        ll ans;
        cin>>ans;
        cout<<ans<<endl;
        cout.flush();
    }else{
        cin>>n;
        vector<ll> b(n);
        for(ll i=0;i<n;i++){
            cin>>b[i];
        }
        sort(b.begin(),b.end());
        ll n2;
        cin>>n2;
        vector<ll> a(n2);
        for(ll i=0;i<n2;i++) cin>>a[i];
        ll res=1;
        if(n != n2) res=0;
        else{
            for(ll i=0;i<n;i++){
                if(a[i] != b[i]){
                    res=0;
                    break;
                }
            }
        }
        cout<<res<<endl;
        cout.flush();
    }
}
signed main(int argc, char *argv[]) {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll T = 1;
//cin >> T;
int role = stoi(argv[1]);
while (T--)
solve(role);
return 0;
}
posted @ 2026-10-13 15:43  yi_one  阅读(6)  评论(0)    收藏  举报