Submission #607582

# Submission time Handle Problem Language Result Execution time Memory
607582 2022-07-26T20:31:14 Z leaked Sorting (IOI15_sorting) C++17
0 / 100
998 ms 43336 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define m_p make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define vec vector

using namespace std;
template <class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template <class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}

typedef long long ll;
typedef pair<int,int> pii;



int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]){
    vec<bool> used(n,0);

    vec<int> obr(n);

    for(int i=0;i<n;i++) obr[s[i]]=i;
    int it=0;

    auto _swap=[&](int i,int j){
////        p[it]=i;q[it]=j;
//        ++it;
        swap(obr[s[i]],obr[s[j]]);
        swap(s[i],s[j]);
    };

//    for(int i=0;i<m;i++){
//        _swap(x[i],y[i]);
//    }
    for(int i=0;i<m;i++){
        _swap(x[i],y[i]);

        vec<int> ct=obr;
        vec<int> cs;
        for(int j=0;j<n;j++) cs.pb(s[j]);

        for(int j=i+1;j<m;j++){
            _swap(x[j],y[j]);
        }



        vec<int> ids;
        for(int f=0;f<n;f++){
            if(s[f]!=f)
                ids.pb(f);
        }


        if(sz(ids)){
//            cout<<"POSSIBLE T\n";
//            for(int f=0;f<n;f++)
//                cout<<s[f]<<' ';
//            cout<<endl;

            int j=ids[0];
            p[it]=j;q[it]=obr[j];

            for(int f=0;f<n;f++) obr[f]=ct[f],s[f]=cs[f];
            p[it]=obr[p[it]],q[it]=obr[q[it]];
            _swap(p[it],q[it]);
            ++it;
        }
        else{
            for(int f=0;f<n;f++) obr[f]=ct[f],s[f]=cs[f];
            p[it]=q[it]=0;
            it++;
        }
        for(int f=0;f<n;f++)
            cout<<s[f]<<' ';
        cout<<endl;
    }
    return m;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 998 ms 43336 KB Expected EOLN
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 998 ms 43336 KB Expected EOLN
2 Halted 0 ms 0 KB -