Submission #463545

#TimeUsernameProblemLanguageResultExecution timeMemory
463545kilikumaXor Sort (eJOI20_xorsort)C++14
0 / 100
1 ms204 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 = i; while((b<N) && (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:24:12: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   24 |   printf("%d\n", res.size()/2);
      |           ~^     ~~~~~~~~~~~~
      |            |               |
      |            int             std::vector<int>::size_type {aka long unsigned int}
      |           %ld
xorsort.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   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...