답안 #524540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524540 2022-02-09T12:59:34 Z Lobo 정렬하기 (IOI15_sorting) C++17
0 / 100
1 ms 568 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 550

int n, m, a[maxn], s1[maxn], s2[maxn];

int32_t findSwapPairs(int32_t N, int32_t S[], int32_t M, int32_t X[], int32_t Y[], int32_t P[], int32_t Q[]) {
    int n = N;
    int m = M;
    for(int i = 0; i < n; i++) {
        a[i] = S[i];
    }

    for(int i = 0; i < m; i++) {
        s1[i] = X[i];
        s2[i] = Y[i];
    }

    int32_t R = 0;
    for(int i = 0; i < N; i++) {
        if(a[i] != i) {
            P[R] = a[i];
            Q[R] = i;
            swap(a[a[i]],a[i]);
            R++;
        }
    }

    return R;
}

Compilation message

sorting.cpp: In function 'int32_t findSwapPairs(int32_t, int32_t*, int32_t, int32_t*, int32_t*, int32_t*, int32_t*)':
sorting.cpp:21:9: warning: declaration of 'n' shadows a global declaration [-Wshadow]
   21 |     int n = N;
      |         ^
sorting.cpp:18:5: note: shadowed declaration is here
   18 | int n, m, a[maxn], s1[maxn], s2[maxn];
      |     ^
sorting.cpp:22:9: warning: declaration of 'm' shadows a global declaration [-Wshadow]
   22 |     int m = M;
      |         ^
sorting.cpp:18:8: note: shadowed declaration is here
   18 | int n, m, a[maxn], s1[maxn], s2[maxn];
      |        ^
sorting.cpp:35:23: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   35 |             P[R] = a[i];
      |                    ~~~^
sorting.cpp:36:20: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   36 |             Q[R] = i;
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 296 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 300 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 568 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 568 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -