답안 #1090655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090655 2024-09-18T15:03:43 Z owoovo 정렬하기 (IOI15_sorting) C++17
20 / 100
1 ms 604 KB
#include "sorting.h"

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	int u=1;
	for(int i=0;i<M;i++)if(X[i]!=0||Y[i]!=0)u=0;
	int ans=0,vis[110]={0};
	if(u==1){
		for(int i=0;i<N;i++){
			if(vis[i]||S[i]==i)continue;
			int now=S[i];
			vis[i]=1;
			while(now!=i){
				vis[now]=1;
				P[ans]=now;
				Q[ans]=i;
				now=S[now];
				ans++;
			}
		}
		return ans;

	}else{
		for(int i=0;i<N;i++){
			if(vis[i]||S[i]==i)continue;
			int now=S[i];
			vis[i]=1;
			while(now!=i){
				ans++;
				vis[now]=1;
				if(now==0||now==1){
					P[ans-1]=now^(ans%2);
				}
				if(i==0||i==1){
					Q[ans-1]=now^(ans%2);
				}
				now=S[now];
			}
		}
		if(ans%2==1){
			P[ans]=0;
			Q[ans]=0;
			ans++;
		}
		return ans;

	}
}


# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Integer 5 violates the range [0, 4]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 424 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Incorrect 0 ms 348 KB Integer 5 violates the range [0, 4]
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -