이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "sorting.h"
using namespace std;
vector<int> s;
int n;
int p[100000];
int q[100000];
void finish(int x) {
cout << "Takes " << x << "\n";
for (int i = 0; i < x; i++)
{
cout << "Round " << i << ": swap " << p[i] << " and " << q[i] << "\n";
}
return;
}
bool sorted() {
for (int i = 0; i < n; i++)
{
if (s[i] != i)
{
return false;
}
}
return true;
}
int findSwapPairs(int N,int S[],int M, int X[],int Y[], int P[],int Q[]) {
for (int i = 0; i < M; i++)
{
P[i] = 0;
Q[i] = 0;
}
n = N;
for (int i = 0; i < N; i++)
{
s.push_back(S[i]);
}
for (int i = 0; i < N; i++)
{
if (sorted())
{
//finish(N-1-i);
return i;
}
swap(s[X[i]], s[Y[i]]);
swap(S[X[i]], S[Y[i]]);
/*cout << "He swaps " << X[N-1-i] << " and " << Y[N-1-i] << "\n";
cout << "Sequence is now: ";
for (int k = 0; k < n; k++)
{
cout << s[k] << " ";
}
cout << "\n";*/
for (int j = 0; j < N; j++)
{
if (S[j] == i)
{
P[i] = j;
p[i] = j;
Q[i] = i;
q[i] = i;
swap(s[j], s[i]);
swap(S[j], S[i]);
/*cout << "We swap " << j << " and " << i << "\n";
cout << "Sequence is now: ";
for (int k = 0; k < n; k++)
{
cout << s[k] << " ";
}
cout << "\n";*/
break;
}
if (j == N-1)
{
assert(false);
}
}
}
//finish(N);
assert(false);
return N;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |