Submission #1080010

#TimeUsernameProblemLanguageResultExecution timeMemory
1080010TrumlingSorting (IOI15_sorting)C++14
0 / 100
22 ms28100 KiB
#include "sorting.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define all(x) x.begin(),x.end() #define INF 9999999999999999 typedef long long ll; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { ll pos[N]; for(int i=0;i<N;i++) { pos[S[i]]=i; } // for(int i=0;i<N;i++) // cout<<pos[i]<<' '; // cout<<'\n'; vector<pair<ll,ll>>v; ll n=N; ll idx=0;swap(S[0],S[1]); for(int i=0;i<n;i++) for(int j=0;j<n-1;j++) { if(S[j]>S[j+1]) { v.pb({j,j+1}); swap(S[j],S[j+1]); idx=1-idx; swap(S[0],S[1]); } } for(int i=0;i<v.size();i++) { P[i]=v[i].F; Q[i]=v[i].S; } // for(int i=0;i<N;i++) // cout<<S[i]<<' '; return v.size(); }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:45:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   for(int i=0;i<v.size();i++)
      |               ~^~~~~~~~~
sorting.cpp:5:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    5 |     #define F first
sorting.cpp:47:15: note: in expansion of macro 'F'
   47 |     P[i]=v[i].F;
      |               ^
sorting.cpp:6:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    6 |     #define S second
sorting.cpp:48:15: note: in expansion of macro 'S'
   48 |     Q[i]=v[i].S;
      |               ^
sorting.cpp:54:19: warning: conversion from 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   54 |      return v.size();
      |             ~~~~~~^~
sorting.cpp:14:9: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
   14 |      ll pos[N];
      |         ^~~
sorting.cpp:12:43: warning: unused parameter 'M' [-Wunused-parameter]
   12 |     int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                       ~~~~^
sorting.cpp:12:50: warning: unused parameter 'X' [-Wunused-parameter]
   12 |     int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                              ~~~~^~~
sorting.cpp:12:59: warning: unused parameter 'Y' [-Wunused-parameter]
   12 |     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...