# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1014698 | 2024-07-05T09:48:11 Z | MarwenElarbi | 정렬하기 (IOI15_sorting) | C++17 | 7 ms | 1372 KB |
#include <bits/stdc++.h> //#include "sorting.h" using namespace std; #define ll long long #define pb push_back #define se second #define fi first vector<pair<int,int>> tab; vector<int> x,y; int cnt=0; vector<pair<int,int>> daq(int l,int r){ if(l==r) return {tab[l]}; int mid=(r+l)/2; vector<pair<int,int>> none; vector<pair<int,int>> a=daq(l,mid); vector<pair<int,int>> b=( mid+1<=r ? daq(mid+1,r) : none); int j=0; vector<pair<int,int>> cur; for (int i = 0; i < (int)a.size(); ++i) { while(j<(int)b.size()&&b[j].fi<a[i].fi){ cur.pb(b[j]); j++; } cur.pb(a[i]); } while(j<(int)b.size()) cur.pb(b[j++]); for (int i = 0; i < (int)cur.size(); ++i) { x.pb(cur[i].se); y.pb(i+l); for (int k = 0; k < (int)cur.size(); ++k) { if(cur[k].se==i+l) cur[k].se=cur[i].se; } cur[i].se=i+l; } return cur; } int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { for (int i = 0; i < N; ++i) { tab.pb({S[i],i}); } /*bool test=(Y[0]==1); if(test) swap(tab[0].se,tab[1].se); sort(tab.begin(),tab.end()); for (int i = 0; i < N; ++i) if(tab[i].se==0) swap(tab[i].se,tab[0^test].se); P[cnt]=tab[0].se; Q[cnt]=0; cnt++; if(test) swap(tab[0].se,tab[1].se); for (int i = 0; i < N; ++i) if(tab[i].se==1) swap(tab[i].se,tab[1^test].se); P[cnt]=tab[1].se; Q[cnt]=1^test; cnt++; for (int i = 2; i < N; ++i) { tab[i]={S[i],i}; }*/ daq(0,N-1); for (int i = 0; i < (int)x.size(); ++i) { P[i]=x[i]; } for (int i = 0; i < (int)y.size(); ++i) { Q[i]=y[i]; } return (int)x.size(); } /* int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int N, M; cin>>N; int *S = (int*)malloc(sizeof(int) * (unsigned int)N); for (int i = 0; i < N; ++i) cin>>S[i]; cin>>M; int *X = (int*)malloc(sizeof(int) * (unsigned int)M), *Y = (int*)malloc(sizeof(int) * (unsigned int)M); for (int i = 0; i < M; ++i) { cin>>X[i]>>Y[i]; } int *P = (int*)malloc(sizeof(int) * (unsigned int)M), *Q = (int*)malloc(sizeof(int) * (unsigned int)M); int ans = findSwapPairs(N, S, M, X, Y, P, Q); cout <<ans<<endl; for (int i = 0; i < ans; ++i) cout <<P[i]<<" "<<Q[i]<<endl; return 0; } */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Incorrect | 0 ms | 348 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 1372 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 1372 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |