Submission #789981

#TimeUsernameProblemLanguageResultExecution timeMemory
789981PoonYaPatSorting (IOI15_sorting)C++14
0 / 100
1 ms340 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; int n,m,a[200005],pos[200005]; vector<pii> v; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { n=N; m=M; for (int i=0; i<n; ++i) a[i]=S[i], pos[a[i]]=i; for (int i=n-1; i>=0; --i) { if (i!=pos[i]) { v.push_back(pii(i,pos[i])); a[pos[i]]=a[i]; a[i]=i; pos[a[i]]=pos[i]; pos[i]=i; } } for (int i=0; i<v.size(); ++i) P[i]=v[i].first, Q[i]=v[i].second; return v.size(); }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for (int i=0; i<v.size(); ++i) P[i]=v[i].first, Q[i]=v[i].second;
      |                ~^~~~~~~~~
sorting.cpp:24:15: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   24 |  return v.size();
      |         ~~~~~~^~
sorting.cpp:9:46: warning: unused parameter 'X' [-Wunused-parameter]
    9 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:9:55: warning: unused parameter 'Y' [-Wunused-parameter]
    9 | 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...