Submission #421706

# Submission time Handle Problem Language Result Execution time Memory
421706 2021-06-09T11:09:17 Z Pbezz Sorting (IOI15_sorting) C++14
0 / 100
358 ms 14776 KB
#include "sorting.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;

const ll MAXN=2e5+5;
const ll INF=1e9+7;



int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	int i,k,j,R=0;
	bool ok=true;
	for(i=0;i<N;i++){
	if(S[i]!=i)ok=false;
	}
	if(ok)return 0;

	swap(S[X[0]],S[Y[0]]);

	ok=true;
	for(i=0;i<N;i++){
	if(S[i]!=i)ok=false;
	}
	if(ok){
	P[R]=0;	Q[R]=0;	R++;
	return 0;
	}

	int fim[N];

	for(i=0;i<N;i++)fim[i]=i;

	for(j=0;j<M;j++){
	swap( fim[X[j]], fim[Y[j]] );
	}

	//fim[i] e a pos inicial que vai acabar em i

	for(i=0;i<N;i++){//fixar o i
//ver pos que faz com que o i acabe bem
//que e fim[i]
cout<<i<<endl;
	for(k=0;k<N;k++){
	if(S[k]==i)break;
	}

for(j=0;j<N;j++){
cout<<fim[j]<<" ";
}cout<<endl<<endl;


P[R]=fim[i];
Q[R]=k;
R++;
swap(S[fim[i]],S[k]);

//atualizar fim

	swap( fim[X[i+1]], fim[Y[i+1]] );





}

while(R<M){

P[R]=0;
Q[R]=0;
R++;

}




	return R;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Hacked
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Hacked
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Hacked
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Hacked
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 14776 KB Hacked
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 14776 KB Hacked
2 Halted 0 ms 0 KB -