# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484063 | 2021-11-02T03:09:24 Z | Cross_Ratio | Sorting (IOI15_sorting) | C++14 | 1 ms | 332 KB |
#include <bits/stdc++.h> #include "sorting.h" using namespace std; typedef pair<long long int, int> P; vector<P> So; vector<long long int> S; vector<int> X, Y; vector<long long int> idx; inline int id(long long int n) { return lower_bound(idx.begin(),idx.end(),n)-idx.begin(); } int N; int findSwapPairs(int N2, int S2[], int M, int X2[], int Y2[], int P1[], int P2[]) { N = N2; int i, j; for(i=0;i<N;i++) { S.push_back(S2[i]); X.push_back(X2[i]); Y.push_back(Y2[i]); } for(i=0;i<N;i++) { S[i] = N * S[i] + i; idx.push_back(S[i]); } sort(idx.begin(),idx.end()); vector<int> Sk; Sk.resize(N); for(i=0;i<N;i++) Sk[id(S[i])] = i; /* for(i=0;i<N;i++) cout << Sk[i] << ' '; cout << '\n'; */ int cnt = 0; for(i=2;i<N;i++) { if(i == Sk[i]) continue; P1[cnt] = i; P2[cnt] = Sk[i]; swap(S[i],S[Sk[i]]); Sk[id(S[P1[cnt]])] = P1[cnt]; Sk[id(S[P2[cnt]])] = P2[cnt]; cnt++; swap(S[0],S[1]); Sk[id(S[0])] = 0; Sk[id(S[1])] = 1; /* for(int j=0;j<N;j++) cout << S[j]/N << ' '; cout << '\n'; for(int j=0;j<N;j++) cout << Sk[j] << ' '; cout << "\n\n"; */ } if(S[0] < S[1]) { P1[cnt] = 0; P2[cnt] = 1; cnt++; } //for(i=0;i<N;i++) cout << S[i]/N <<' '; return cnt; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Incorrect | 0 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |