Submission #560329

# Submission time Handle Problem Language Result Execution time Memory
560329 2022-05-11T09:54:19 Z Koosha_mv Sorting (IOI15_sorting) C++14
20 / 100
1 ms 372 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "sorting.h"
 
const int N=2020;
 
int n,m,a[N],b[N],s[N],t[N],pos[N],mark[N];
vector<pair<int,int>> ans;

int findSwapPairs(int _n, int A[], int _m, int S[], int T[], int P[], int Q[]) {
  n=_n,m=_m;
  f(i,0,n) a[i]=A[i];
  f(i,0,m) P[i]=Q[i]=0;
  f(i,0,n) pos[a[i]]=i;
  int cnt=0;
	f(i,0,n){
		/*if(pos[i]!=i){
			P[cnt]=i;
			Q[cnt]=pos[i];
			swap(pos[i],pos[a[i]]);
			swap(a[P[cnt]],a[Q[cnt]]);
			cnt++;
		}*/
		while(a[i]!=i){
			P[cnt]=i;
			Q[cnt]=a[i];
			swap(a[P[cnt]],a[Q[cnt]]);
			cnt++;
		}
	}
	if(cnt>m){
		eror(2);
		eror(1);
		assert(0);
	}
	return cnt;
}
/*
int32_t main(){
	srand(time(NULL));
	int n,m,a[100],s[100],t[100],p[100],q[100];
	cin>>n;
	m=n*n;
	//f(i,0,n) cin>>a[i];
	iota(a,a+n,0); //random_shuffle(a,a+n);
	do{
		cout<<endl<<endl;
		f(i,0,m) s[i]=t[i]=0;
		dbga(a,0,n);
		cout<<findSwapPairs(n,a,m,s,t,p,q)<<"R"<<'\n';
	} while(next_permutation(a,a+n));
}*/

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:20:11: warning: unused parameter 'second' [-Wunused-parameter]
   20 | #define S second
      |           ^
sorting.cpp:29:48: note: in expansion of macro 'S'
   29 | int findSwapPairs(int _n, int A[], int _m, int S[], int T[], int P[], int Q[]) {
      |                                                ^
sorting.cpp:29:57: warning: unused parameter 'T' [-Wunused-parameter]
   29 | int findSwapPairs(int _n, int A[], int _m, int S[], int T[], int P[], int Q[]) {
      |                                                     ~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Incorrect 1 ms 304 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 304 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Incorrect 1 ms 304 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -