답안 #921742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921742 2024-02-04T09:46:09 Z coding_snorlax 정렬하기 (IOI15_sorting) C++14
0 / 100
4 ms 348 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
int S[1000]={1,0,2},X[1000]={0,0,0,0,0},Y[1000]={0,0,0,0,0},P[1000],Q[1000];
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    for(int i=2;i<N;i++){
        int tmp = S[X[i]];
        S[X[i]]=S[Y[i]];
        S[Y[i]]=tmp;
        for(int j=0;j<N;j++){
            if(S[j]==i){
                P[i-2]=j;
                Q[i-2]=i;
                S[j]=S[i];
                S[i]=i;
                break;
            }
        }
        // check already_sorted
        int flag = 1;
        for(int j=0;j<N;j++){
            if(S[j]!=j) flag =0;
        }
        if(flag){
            return i-1;
        }
    }
    P[N-2]=0;Q[N-2]=1;
	return N-1;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:5:73: warning: declaration of 'Q' shadows a global declaration [-Wshadow]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                                     ~~~~^~~
sorting.cpp:4:69: note: shadowed declaration is here
    4 | int S[1000]={1,0,2},X[1000]={0,0,0,0,0},Y[1000]={0,0,0,0,0},P[1000],Q[1000];
      |                                                                     ^
sorting.cpp:5:64: warning: declaration of 'P' shadows a global declaration [-Wshadow]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                            ~~~~^~~
sorting.cpp:4:61: note: shadowed declaration is here
    4 | int S[1000]={1,0,2},X[1000]={0,0,0,0,0},Y[1000]={0,0,0,0,0},P[1000],Q[1000];
      |                                                             ^
sorting.cpp:5:55: warning: declaration of 'Y' shadows a global declaration [-Wshadow]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
sorting.cpp:4:41: note: shadowed declaration is here
    4 | int S[1000]={1,0,2},X[1000]={0,0,0,0,0},Y[1000]={0,0,0,0,0},P[1000],Q[1000];
      |                                         ^
sorting.cpp:5:46: warning: declaration of 'X' shadows a global declaration [-Wshadow]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:4:21: note: shadowed declaration is here
    4 | int S[1000]={1,0,2},X[1000]={0,0,0,0,0},Y[1000]={0,0,0,0,0},P[1000],Q[1000];
      |                     ^
sorting.cpp:5:30: warning: declaration of 'S' shadows a global declaration [-Wshadow]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                          ~~~~^~~
sorting.cpp:4:5: note: shadowed declaration is here
    4 | int S[1000]={1,0,2},X[1000]={0,0,0,0,0},Y[1000]={0,0,0,0,0},P[1000],Q[1000];
      |     ^
sorting.cpp:5:39: warning: unused parameter 'M' [-Wunused-parameter]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -