답안 #607584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
607584 2022-07-26T20:31:31 Z leaked 정렬하기 (IOI15_sorting) C++17
16 / 100
162 ms 400 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;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 30 ms 340 KB Output is correct
4 Correct 32 ms 340 KB Output is correct
5 Correct 34 ms 344 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 162 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 162 ms 400 KB Output isn't correct
2 Halted 0 ms 0 KB -