Submission #465483

#TimeUsernameProblemLanguageResultExecution timeMemory
465483idasXor Sort (eJOI20_xorsort)C++11
0 / 100
1 ms204 KiB
#include<bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin); i<(end); i++) #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr) #define PB push_back #define F first #define S second const int INF=1e9; const long long LINF=1e18; using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; typedef map<int, int> mii; const int N=1e4+10; int n, s, a[N]; int main() { FAST_IO; cin >> n >> s; FOR(i, 0, n) { cin >> a[i]; } vector<pii> ans; FOR(i, 1, n) { int xr=(a[i-1]^a[i]); if(xr<a[i]){ a[i-1]=xr; ans.PB({i, i+1}); } else{ a[i]=xr; ans.PB({i+1, i}); } } cout << ans.size() << '\n'; for(auto[x, y] : ans){ cout << x << " " << y << '\n'; } }

Compilation message (stderr)

xorsort.cpp: In function 'int main()':
xorsort.cpp:44:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |     for(auto[x, y] : ans){
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...