제출 #137997

#제출 시각아이디문제언어결과실행 시간메모리
137997arthurconmySorting (IOI15_sorting)C++14
0 / 100
1081 ms376 KiB
#include <bits/stdc++.h> using namespace std; int eend[501]; int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]) { // cout << n << endl; for(int i=0; i<n; i++) { eend[i]=S[i]; } for(int i=0; i<m; i++) { swap(eend[X[i]],eend[Y[i]]); } //f//or(int i=0; i<n; i++) //{ //cout << i << " " << eend[i] << endl; //} // return 7; int cur_sort=0; // cout << "HERE" << endl; for(int i=0; i<m; i++) { //cout << i << endl; swap(eend[X[i]],eend[Y[i]]); swap(S[X[i]],S[Y[i]]); bool upd=0; while(cur_sort < n) { // find cur_sort in both arrays int pos_s=-1; int pos_e=-1; for(int j=0; j<n; i++) { if(S[j]==cur_sort) pos_s=j; if(eend[j]==cur_sort) pos_e=j; } if(pos_e == pos_s) { // cout << cur_sort << " is sorted bro" << endl; cur_sort++; continue; } swap(S[pos_s],S[pos_e]); P[i]=pos_s; Q[i]=pos_e; upd=1; cur_sort++; break; } if(!upd) { P[i]=0; Q[i]=0; } // cout << P[i] << " " << Q[i] << endl; } return m; }
#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...