답안 #1117535

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117535 2024-11-23T22:04:46 Z allin27x 정렬하기 (IOI15_sorting) C++17
0 / 100
10 ms 348 KB
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;

int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
    vector<int> a(n); iota(a.begin(), a.end(), 0);
    for (int i=m-1; i>=0; i--) swap(a[x[i]], a[y[i]]);
    for (int ind=0; ind<m; ind++) {
        swap(a[x[ind]], a[y[ind]]); swap(s[x[ind]], s[y[ind]]);
        int f = 0;
        for (int i=0; i<n; i++) {
            if (f) break;
            if (a[i] != s[i]) {
                for (int j=0; j<n; j++) {
                    if (a[j] == s[i]) {
                        p[ind] = i; q[ind] = j;
                        swap(s[i], s[j]);
                        f = 1;
                    }
                }
            }
        }
        if (!f) p[ind] = 0, q[ind] = 0;
        f = 0; for (int i=0; i<n; i++) if(a[i] !=s[i]) f++;
    }
    return m;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Incorrect 1 ms 336 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -