Submission #1018524

# Submission time Handle Problem Language Result Execution time Memory
1018524 2024-07-10T06:30:05 Z huutuan Sorting (IOI15_sorting) C++14
16 / 100
7 ms 516 KB
#include "sorting.h"

#include <bits/stdc++.h>

using namespace std;

int a[200010];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
   if (is_sorted(S, S+N)) return 0;
   iota(a, a+N, 0);
   for (int i=M-1; i>=0; --i) swap(a[X[i]], a[Y[i]]);
   for (int i=0; i<M; ++i){
      swap(a[X[i]], a[Y[i]]);
      swap(S[X[i]], S[Y[i]]);
      for (int j=0; j<N; ++j) if (a[j]!=S[j]){
         int k=find(S, S+N, a[j])-S;
         P[i]=j; Q[i]=k;
         swap(S[j], S[k]);
         break;
      }
   }
   return M;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:17:34: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   17 |          int k=find(S, S+N, a[j])-S;
      |                ~~~~~~~~~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 516 KB Output isn't correct
2 Halted 0 ms 0 KB -