Submission #1083203

#TimeUsernameProblemLanguageResultExecution timeMemory
1083203MalixSorting (IOI15_sorting)C++14
20 / 100
1 ms516 KiB
#include "sorting.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef pair<int,int> pi; typedef vector<pi> pii; typedef tuple<int,int,int> tii; typedef vector<ll> li; typedef vector<li> lii; #define REP(i,a,b) for(int i=a;i<b;i++) #define F first #define S second #define PB push_back #define LSOne(s) ((s)&(-s)) ll INF=1000000000000000010; int inf=1e9+10; ll M=1e9+7; int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) { vi a(n),b(n); if(n==1)return 0; int ans=0; REP(i,0,n)a[S[i]]=i; REP(i,0,n)b[i]=S[i]; int pos=0; for(int i=n-1;i>=0;i--){ if(Y[0]==1){ int p=a[0],q=a[1]; swap(b[p],b[q]); a[0]=q;a[1]=p; } if(a[i]==i)continue; ans++; P[pos]=i; Q[pos]=a[i]; pos++; swap(b[i],b[a[i]]); int x=b[a[i]]; int y=a[i]; a[i]=i; a[x]=y; } return ans; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:24:39: warning: declaration of 'M' shadows a global declaration [-Wshadow]
   24 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:22:4: note: shadowed declaration is here
   22 | ll M=1e9+7;
      |    ^
sorting.cpp:24:39: warning: unused parameter 'M' [-Wunused-parameter]
   24 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:24:46: warning: unused parameter 'X' [-Wunused-parameter]
   24 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
#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...