답안 #484037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
484037 2021-11-01T23:45:17 Z Cross_Ratio 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 460 KB
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;
typedef pair<long long int, int> P;
vector<P> So;
vector<long long int> S;
vector<int> X, Y;
int N;
int findSwapPairs(int N2, int S2[], int M, int X2[], int Y2[], int P1[], int P2[]) {
    N = N2;
    int i, j;
    for(i=0;i<N;i++) {
        So.push_back(P(S2[i],i));
        S.push_back(S2[i]);
        X.push_back(X2[i]);
        Y.push_back(Y2[i]);
    }
    for(i=0;i<N;i++) {
        So[i].first = N * So[i].first + i;
        S[i] = N * S[i] + i;
    }
    sort(So.begin(),So.end());
    int cnt = 0;
    for(i=0;i<N;i++) {
        if(S[i] == So[i].first) continue;
        P1[cnt] = i;
        P2[cnt] = So[i].second;
        swap(S[i],S[So[i].second]);
        cnt++;
    }
    return cnt;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:11:12: warning: unused variable 'j' [-Wunused-variable]
   11 |     int i, j;
      |            ^
sorting.cpp:9:41: warning: unused parameter 'M' [-Wunused-parameter]
    9 | int findSwapPairs(int N2, int S2[], int M, int X2[], int Y2[], int P1[], int P2[]) {
      |                                     ~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 284 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 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 284 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 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 284 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Incorrect 0 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -