1 条题解

  • 0
    @ 2026-7-13 14:51:22

    用set就行了。

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        freopen("set.in","r",stdin);
        freopen("set.out","w",stdout);
        int t,n;
        cin>>t;
        for (int i = 0; i < t; i++) {
            cin>>n;
            set<int> a;
            set<int> b;
            for (int j = 0; j < n; j++) {
                int x;
                cin>>x;
                a.insert(x);
            }
            for (int j = 0; j < n; j++) {
                int x;
                cin>>x;
                b.insert(x);
            }
            if (a == b) {
                cout<<"yes"<<endl;
            } else {
                cout<<"no"<<endl;
            }
        }
        return 0;
    }
    
    
    • 1

    信息

    ID
    138
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    90
    已通过
    16
    上传者