Submission #383211

#TimeUsernameProblemLanguageResultExecution timeMemory
383211aris12345678Xor Sort (eJOI20_xorsort)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6+5; int a[mxN]; int main() { int n, s; scanf("%d%d", &n, &s); for(int i = 0; i < n; i++) scanf("%d", &a[i]); vector<pair<int, int> > ans; for(int i = 0; i < n; i++) { for(int j = 0; j < n-i-1; j++) { if(a[j] > a[j+1]) { swap(a[j], a[j+1]); ans.push_back({j, j+1}), ans.push_back({j+1, j}), ans.push_back({j, j+1}); } } } printf("%lu\n", ans.size()); for(int i = 0; i < ans.size(); i++) printf("%d %d\n", ans[i].first, ans[i].second); return 0; }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < ans.size(); i++)
      |                    ~~^~~~~~~~~~~~
xorsort.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d%d", &n, &s);
      |     ~~~~~^~~~~~~~~~~~~~~~
xorsort.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...