답안 #621021

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

void mer(int l,int r)
{
    /*
    if(l==r)return;
    int mid=(l+r)/2;
    mer(l,mid);
    mer(mid+1,r);

    int l1=l;
    int l2=mid+1;
    while(l1<=mid&&l2<=r){
        if(a[l1]>a[l2]){

        }
    }

    */

}

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];
    }




//    mer(0,n-1);

    for(int i=0;i<n;i++){
        int f=1;
        for(int j=1;j<n-1;j++){
            if(a[j+1]<a[j]){
                swap(a[j],a[j+1]);
                P[num]=j;
                Q[num]=j+1;
                num++;
                f=1;
                for(int h=0;h<n-1;h++){
                    if(a[h]>a[h+1])f=0;
                }
                if(f==1)break;
                swap(a[0],a[1]);
                f=1;
                for(int h=0;h<n-1;h++){
                    if(a[h]>a[h+1])f=0;
                }
                if(f==1){
                    P[num]=0;
                    Q[num]=0;
                    num++;
                    break;
                }
            }
            if(f==1)break;
        }
    }
    return num;
}













Compilation message

sorting.cpp: In function 'void mer(int, int)':
sorting.cpp:11:14: warning: unused parameter 'l' [-Wunused-parameter]
   11 | void mer(int l,int r)
      |          ~~~~^
sorting.cpp:11:20: warning: unused parameter 'r' [-Wunused-parameter]
   11 | void mer(int l,int r)
      |                ~~~~^
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:31:23: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   31 | 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:31:39: warning: unused parameter 'M' [-Wunused-parameter]
   31 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:31:46: warning: unused parameter 'X' [-Wunused-parameter]
   31 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:31:55: warning: unused parameter 'Y' [-Wunused-parameter]
   31 | 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 0 ms 212 KB Output is correct
2 Incorrect 1 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 6 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -