Submission #484041

# Submission time Handle Problem Language Result Execution time Memory
484041 2021-11-01T23:47:52 Z Cross_Ratio Sorting (IOI15_sorting) C++14
0 / 100
1 ms 332 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;
    }
    sort(So.begin(),So.end());
    int cnt = 0;
    for(i=0;i<N;i++) {
        if(i == So[i].second) 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:15:12: warning: unused variable 'j' [-Wunused-variable]
   15 |     int i, j;
      |            ^
sorting.cpp:13:41: warning: unused parameter 'M' [-Wunused-parameter]
   13 | int findSwapPairs(int N2, int S2[], int M, int X2[], int Y2[], int P1[], int P2[]) {
      |                                     ~~~~^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -