Submission #463555

#TimeUsernameProblemLanguageResultExecution timeMemory
463555kilikumaXor Sort (eJOI20_xorsort)C++14
25 / 100
124 ms12380 KiB
#include <bits/stdc++.h> using namespace std; int main() { int A[1005]; int N; cin >>N; int id; cin >> id; for (int i=1;i<=N;i++) cin >> A[i]; vector<int> res; for (int i=1; i<= N; i++) { int b = 1; while((b<N) ) { if (A[b] > A[b+1]) { res.push_back(b); res.push_back(b+1); res.push_back(b+1); res.push_back(b); res.push_back(b); res.push_back(b+1); swap(A[b], A[b+1]); } b ++; } } printf("%d\n", res.size()/2); for (int i=0;i<res.size(); i+=2) { printf("%d %d\n", res[i], res[i+1]); } }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:26:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   26 |   printf("%d\n", res.size()/2);
      |           ~^     ~~~~~~~~~~~~
      |            |               |
      |            int             std::vector<int>::size_type {aka long unsigned int}
      |           %ld
xorsort.cpp:27:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for (int i=0;i<res.size(); i+=2) {
      |                ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...