Submission #794906

#TimeUsernameProblemLanguageResultExecution timeMemory
794906Username4132Sorting (IOI15_sorting)C++14
0 / 100
3 ms3412 KiB
#include "sorting.h" #include<iostream> #include<algorithm> using namespace std; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define forsn(i, s, n) for(int i=s; i<(int)n; ++i) const int MAXN = 610; int n, cou, arr[MAXN][MAXN]; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { n=N; forn(i, n) arr[0][i]=S[i]; forn(i, n-1){ forn(j, n) arr[i+1][j]=arr[i][j]; swap(arr[i+1][X[i]], arr[i+1][Y[i]]); } forn(i, n-1){ int num = arr[n-1][i]; forsn(j, i+1, n){ int x = find(arr[j], arr[j]+n, num) - arr[j]; int y = find(arr[j], arr[j]+n, i) - arr[j]; swap(arr[j][x], arr[j][y]); if(j==i+1 && x!=y) P[cou]=x, Q[cou]=y, ++cou; } } P[cou]=Q[cou]=0; return cou+1; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:21:40: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   21 |    int x = find(arr[j], arr[j]+n, num) - arr[j];
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
sorting.cpp:22:38: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   22 |    int y = find(arr[j], arr[j]+n, i) - arr[j];
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
sorting.cpp:11:39: warning: unused parameter 'M' [-Wunused-parameter]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...