Submission #1075125

# Submission time Handle Problem Language Result Execution time Memory
1075125 2024-08-25T18:48:03 Z ArthuroWich Sorting (IOI15_sorting) C++17
0 / 100
3 ms 1664 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
int findSwapPairs(int n, int p[], int M, int X[], int Y[], int P[], int Q[]) {
    vector<pair<int, int>> ans;
    int d = 0;
    for (int i = n-1; i >= 0; i++) {
        if (p[i] == i) {
            continue;
        }
        while(p[i] != i) {
            int j = p[i];
            ans.push_back({i, j});
            swap(p[i], p[j]);
            if (is_sorted(p, p+n)) {
                break;
            }
            swap(X[d], Y[d]);
            d++;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        P[i] = ans[i].first;
        Q[i] = ans[i].second;
    }
    return ans.size();
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
sorting.cpp:26:20: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   26 |     return ans.size();
      |            ~~~~~~~~^~
sorting.cpp:4:39: warning: unused parameter 'M' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int p[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1664 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1664 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -