Submission #707925

#TimeUsernameProblemLanguageResultExecution timeMemory
707925josanneo22Xor Sort (eJOI20_xorsort)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> #include<iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, s; cin >> n >> s; vector<int> a(n); for (auto& x : a) cin >> x; vector<pair<int, int>> ans; if (s == 1) { for (int i = 1; i < n; i++) { if (a[i] < a[i - 1]) { ans.push_back(make_pair(i,i-1)); ans.push_back(make_pair(i-1, i)); ans.push_back(make_pair(i, i - 1)); swap(a[i], a[i - 1]); } } } for (int i = 0; i < ans.size(); i++) { cout << ans[i].first+1 << ' ' << ans[i].second+1 << '\n'; } }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:20: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]
   20 |  for (int i = 0; i < ans.size(); i++) {
      |                  ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...