Submission #878319

#TimeUsernameProblemLanguageResultExecution timeMemory
878319konberXor Sort (eJOI20_xorsort)C++14
25 / 100
98 ms14116 KiB
#include <iostream> #include <vector> using namespace std; vector<int> a; vector<pair<int, int>> k; int N; void bubble_sort(){ for(int j=0; j < N; j++){ for(int i=N-1; i > j; i--){ if(a[i] < a[i-1]){ swap(a[i], a[i-1]); k.push_back(make_pair(i-1, i)); k.push_back(make_pair(i, i-1)); k.push_back(make_pair(i-1, i)); } } } } int main() { int S; scanf("%d%d", &N, &S); a.resize(N); for(int i=0; i < N; i++) scanf("%d", &a[i]); bubble_sort(); printf("%d\n", k.size()); for(int i=0; i < k.size(); i++){ printf("%d %d\n", k[i].first+1, k[i].second+1); } }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:32:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   32 |     printf("%d\n", k.size());
      |             ~^     ~~~~~~~~
      |              |           |
      |              int         std::vector<std::pair<int, int> >::size_type {aka long unsigned int}
      |             %ld
xorsort.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0; i < k.size(); i++){
      |                  ~~^~~~~~~~~~
xorsort.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     scanf("%d%d", &N, &S);
      |     ~~~~~^~~~~~~~~~~~~~~~
xorsort.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...