Submission #464892

#TimeUsernameProblemLanguageResultExecution timeMemory
464892bigoXor Sort (eJOI20_xorsort)C++14
0 / 100
1093 ms204 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long typedef pair<ll, ll> pii; int main() { int s, n; cin >> n >> s; vector<ll>vec(n); for (int i = 0; i < n; i++) cin >> vec[i]; vector<pii>vec1; vec1.push_back({ 0, 1 }); for (int i = 1; i < n - 1; i++) { vec1.push_back({ i,i - 1 }); vec1.push_back({ i,i + 1 }); } vec1.push_back({ n - 1,n - 2 }); bool fl = true; for (int i = 0; i < n-1; i++) { if (vec[i] >= vec[i + 1]) { fl = false; break; } } if (!fl) { int pla; while (next_permutation(vec1.begin(), vec1.end())) { vector<ll>tmp = vec; bool fl2=false; for (int i = 0; i < vec1.size(); i++) { tmp[vec1[i].first] = (tmp[vec1[i].first] ^ tmp[vec1[i].second]); bool fl1 = true; for (int j = 0; j < n - 1; j++) { if (tmp[j] >= tmp[j + 1]) { fl1 = false; break; } } if (fl1) { pla = i; fl2 = true; break; } } if (fl2) break; } cout << pla + 1 << endl; for (int i = 0; i <= pla; i++) cout << vec1[i].first + 1 << " " << vec1[i].second + 1 << endl; } else cout << 0; }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |    for (int i = 0; i < vec1.size(); i++) {
      |                    ~~^~~~~~~~~~~~~
xorsort.cpp:49:21: warning: 'pla' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |   for (int i = 0; i <= pla; i++)
      |                   ~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...