Submission #973943

#TimeUsernameProblemLanguageResultExecution timeMemory
973943PagodePaivaSorting (IOI15_sorting)C++17
16 / 100
3 ms348 KiB
#include<bits/stdc++.h> #include "sorting.h" using namespace std; int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) { for(int i = 0;i < m;i++) p[i] = q[i] = 0; vector <int> v; for(int i = 0;i < n;i++){ v.push_back(i); } for(int i = n-1;i >= 0;i--){ swap(v[x[i]], v[y[i]]); } for(int i = 0;i < n;i++){ // for(int j = 0;j < n;j++) { // cout << v[j] << ' '; // } // cout << '\n'; swap(v[x[i]], v[y[i]]); swap(s[x[i]], s[y[i]]); int poss, posv; for(int j = 0;j < n;j++){ if(s[j] == i) poss = j; if(v[j] == i) posv = j; } p[i] = poss; q[i] = posv; swap(s[poss], s[posv]); } // for(int j = 0;j < n;j++) cout << v[j] << ' '; // cout << "\n"; // for(int j = 0;j < n;j++) cout << s[j] << ' '; return n; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:29:19: warning: 'posv' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |   swap(s[poss], s[posv]);
      |                   ^~~~
sorting.cpp:29:10: warning: 'poss' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |   swap(s[poss], s[posv]);
      |          ^~~~
#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...