Submission #463555

# Submission time Handle Problem Language Result Execution time Memory
463555 2021-08-11T10:07:47 Z kilikuma Xor Sort (eJOI20_xorsort) C++14
25 / 100
124 ms 12380 KB
#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

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 time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 3 ms 676 KB Output is correct
6 Correct 5 ms 616 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 3 ms 588 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 3 ms 676 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 6 ms 840 KB Output is correct
13 Correct 6 ms 840 KB Output is correct
14 Correct 6 ms 840 KB Output is correct
15 Correct 7 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 588 KB Output is correct
5 Correct 3 ms 676 KB Output is correct
6 Correct 5 ms 616 KB Output is correct
7 Correct 3 ms 588 KB Output is correct
8 Correct 3 ms 588 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 3 ms 676 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 6 ms 840 KB Output is correct
13 Correct 6 ms 840 KB Output is correct
14 Correct 6 ms 840 KB Output is correct
15 Correct 7 ms 892 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 3 ms 588 KB Output is correct
18 Correct 6 ms 840 KB Output is correct
19 Correct 6 ms 868 KB Output is correct
20 Correct 6 ms 840 KB Output is correct
21 Correct 6 ms 816 KB Output is correct
22 Correct 6 ms 800 KB Output is correct
23 Correct 6 ms 884 KB Output is correct
24 Correct 6 ms 840 KB Output is correct
25 Correct 5 ms 840 KB Output is correct
26 Incorrect 10 ms 1188 KB Integer 59568 violates the range [0, 40000]
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 6 ms 840 KB Output is correct
5 Incorrect 124 ms 12380 KB Integer 764742 violates the range [0, 40000]
6 Halted 0 ms 0 KB -