Submission #1218865

#TimeUsernameProblemLanguageResultExecution timeMemory
1218865viduxSorting (IOI15_sorting)C++17
Compilation error
0 ms0 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef pair<ll, ll> pll; typedef vector<ll> vl; const ll LLINF = 1e18; int findSwapPairs(int N, int a[], int M, int X[], int Y[], int P[], int Q[]) { int n = N; int l = 0, r = M; auto opCnt = [&]() -> ll { vi pos(n); vi b(n); ll cnt = 0; for (int i = 0; i < n; i++) pos[a[i]] = i, b[i] = a[i]; for (int i = 0; i < n; i++) { if (pos[i] != i) { int p = pos[i]; swap(b[i], b[p]); swap(pos[i], pos[b[p]]); P[cnt] = i; Q[cnt] = p; cnt++; } } return cnt; }; int ans = opCnt(); //cout << ans << endl; //for (int i = 0; i < ans; i++) cout << P[i] << " " << Q[i] << endl; if (Y[0] == 1 && ans%2) p[ans] = 0, q[ans++] = 1; return ans; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:37:33: error: 'p' was not declared in this scope
   37 |         if (Y[0] == 1 && ans%2) p[ans] = 0, q[ans++] = 1;
      |                                 ^
sorting.cpp:37:45: error: 'q' was not declared in this scope
   37 |         if (Y[0] == 1 && ans%2) p[ans] = 0, q[ans++] = 1;
      |                                             ^