Submission #424465

#TimeUsernameProblemLanguageResultExecution timeMemory
424465OzySorting (IOI15_sorting)C++17
74 / 100
50 ms17972 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debugsl(a) cout << #a << " = " << a << ", " #define debug(a) cout << #a << " = " << a << endl int a, b, n,cant,me; int visitados[2002],id[2002],glob[2002]; int arr[2002],x[2002],y[2002],p[2002],q[2002]; vector<pair<int, int> > intercambios; int cuenta(int c, bool guarda) { int act,res = 0; rep(i,0,n-1) { if (visitados[i] != c) { res++; act = arr[i]; visitados[i] = c; if (guarda && act != arr[act]) intercambios.emplace_back(act, arr[act]); while (act != i) { visitados[act] = c; act = arr[act]; if (guarda && act != i) intercambios.emplace_back(act, arr[act]); } } } return res; } int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { n = N; rep(i,0,n-1) arr[i] = S[i]; a = cuenta(N + 10, false); if (a == N) return 0; rep(i,0,M-1) { swap(arr[X[i]], arr[Y[i]]); a = N - cuenta(i + 1, false); if (a <= (i+1)){ me = i; break; } } cuenta(me + 2, true); rep(i, 0, me){ swap(S[X[i]], S[Y[i]]); if (i < intercambios.size()){ rep(j, 0, N - 1){ if (S[j] == intercambios[i].first) a = j; else if (S[j] == intercambios[i].second) b = j; } P[i] = a; Q[i] = b; swap(S[a], S[b]); } else { P[i] = Q[i] = 0; } } return me + 1; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:58:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         if (i < intercambios.size()){
      |             ~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...