답안 #432549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
432549 2021-06-18T11:00:45 Z daniel920712 정렬하기 (IOI15_sorting) C++14
8 / 100
4 ms 332 KB
#include "sorting.h"
#include <iostream>
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
{
    int i,j,now=0,ok;
    for(i=N-1;i>=0;i--)
    {
        ok=1;
        for(j=0;j<N;j++) if(S[j]!=j) ok=0;
        if(ok) break;
        swap(S[X[now]],S[Y[now]]);
        for(j=0;j<N;j++)
        {
            if(S[j]==i)
            {
                if(i!=j)
                {
                    P[now]=i;
                    Q[now]=j;
                }
                else
                {
                    P[now]=1;
                    Q[now]=0;
                }
                swap(S[P[now]],S[Q[now]]);
                now++;
                break;
            }
        }

    }
    if(S[0]==1)
    {
        if(S[1]!=0) while(1);
        if(X[now]==0&&Y[now]==0)
        {
            P[now]=i;
            Q[now]=j;
            swap(S[P[now]],S[Q[now]]);
            now++;
        }
        else return 1/0;

    }
	return now;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:44:22: warning: division by zero [-Wdiv-by-zero]
   44 |         else return 1/0;
      |                     ~^~
sorting.cpp:4:39: warning: unused parameter 'M' [-Wunused-parameter]
    4 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                   ~~~~^
sorting.cpp:41:35: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |             swap(S[P[now]],S[Q[now]]);
      |                              ~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Incorrect 1 ms 204 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Incorrect 1 ms 204 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -