# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014658 | 2024-07-05T08:59:04 Z | MarwenElarbi | Sorting (IOI15_sorting) | C++17 | 1 ms | 600 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 < a.size(); ++i) { if(j<b.size()&&b[j].fi<a[i].fi){ x.pb(b[j].se); y.pb(a[i].se); swap(a[i].se,b[j].se); cur.pb(b[j]); j++; } cur.pb(a[i]); } while(j<b.size()) cur.pb(b[j++]); 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 < x.size(); ++i) { cnt++; P[i]=x[i]; } for (int i = 0; i < y.size(); ++i) { Q[i]=y[i]; } return cnt; } /* 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 0 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 0 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Incorrect | 0 ms | 348 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Integer parameter [name=R] equals to 5653, violates the range [0, 5400] |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Integer parameter [name=R] equals to 5653, violates the range [0, 5400] |
2 | Halted | 0 ms | 0 KB | - |