답안 #621413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
621413 2022-08-03T18:42:23 Z A_D 정렬하기 (IOI15_sorting) C++14
0 / 100
3 ms 340 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+100;
int a[N];
pair<int,int> b[N];
int n;
int num=0;


int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    num=0;
    n=N;
    for(int i=0;i<N;i++){
        a[i]=S[i];
        b[i]={a[i],i};
    }
    sort(b,b+n);
    for(int i=0;i<n;i++){
        a[b[i].second]=i;
    }
    if(n==1)return num;
    if(Y[0]==1)swap(a[0],a[1]);
    //P[num]=0;Q[num]=0;num++;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[j]==i){
                P[num]=i;
                Q[num]=j;
                swap(a[i],a[j]);
                num++;
                P[num]=0;
                Q[num]=0;
                num++;
            }

        }
    }
    return num;
}













Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:11:23: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                   ~~~~^
sorting.cpp:4:11: note: shadowed declaration is here
    4 | const int N=2e5+100;
      |           ^
sorting.cpp:11:39: warning: unused parameter 'M' [-Wunused-parameter]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:11:46: warning: unused parameter 'X' [-Wunused-parameter]
   11 | 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 Correct 0 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 0 ms 212 KB Output is correct
3 Correct 0 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 1 ms 212 KB Output isn't correct
2 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 Correct 0 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 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -