답안 #552870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552870 2022-04-24T08:25:12 Z elazarkoren 정렬하기 (IOI15_sorting) C++17
0 / 100
2 ms 340 KB
#include "sorting.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
//#define int ll
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;

int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
    int cnt = 0;
    for (int i = 2; i < n; i++) {
        if (s[i] != i) {
            for (int j = 0; j < n; j++) {
                if (s[j] == i) {
                    p[cnt] = i, q[cnt] = j;
                    cnt++;
                    swap(s[i], s[j]);
                    swap(s[0], s[1]);
                    break;
                }
            }
        }
    }
    if (q[0]) {
        p[cnt] = q[cnt] = 0;
        cnt++;
    }
    return cnt;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:17:39: warning: unused parameter 'm' [-Wunused-parameter]
   17 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
      |                                   ~~~~^
sorting.cpp:3:11: warning: unused parameter 'first' [-Wunused-parameter]
    3 | #define x first
      |           ^
sorting.cpp:17:46: note: in expansion of macro 'x'
   17 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
      |                                              ^
sorting.cpp:4:11: warning: unused parameter 'second' [-Wunused-parameter]
    4 | #define y second
      |           ^
sorting.cpp:17:55: note: in expansion of macro 'y'
   17 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
      |                                                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -