답안 #31818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31818 2017-09-10T11:33:15 Z top34051 정렬하기 (IOI15_sorting) C++14
8 / 100
15 ms 512 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
#define maxn 10

int a[maxn], pos[maxn];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    int i,x,now,cnt;
    for(now=-1;now<M;now++) {
        if(now>=0) swap(S[X[now]], S[Y[now]]);

        for(i=0;i<N;i++) a[i] = S[i];
        for(i=0;i<N;i++) pos[a[i]] = i;

        cnt = 0;
        for(i=0;i<N;i++) {
            x = pos[i];
            if(i!=x) {
                pos[a[i]] = x;
                swap(a[i], a[x]);
                P[cnt] = i; Q[cnt] = x;
                cnt++;
            }
        }
        while(cnt<=now) P[cnt] = Q[cnt] = 0, cnt++;

        if(cnt==now+1) {
            for(i=0;i<N;i++) a[i] = i;
            for(i=now;i>=0;i--) {
                P[i] = a[P[i]]; Q[i] = a[Q[i]];
                swap(a[X[i]], a[Y[i]]);
            }
            return now+1;
        }
    }
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -