답안 #1079951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079951 2024-08-29T04:52:25 Z Trumling 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 600 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 9999999999999999
typedef long long ll;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {

	vector<pair<ll,ll>>v;

    for(int i=0;i<M;i++)
			v.pb({P[i],Q[i]});
		
	vector<int>s(N);
	ll r=0;
	do
	{
		for(int i=0;i<N;i++)
			s[i]=S[i];
		
		for(int i=0;i<M;i++)
		{
			swap(s[v[i].F],s[v[i].S]);
			bool tf=1;
			for(int j=0;j<N-1;j++)
				if(s[j]>s[j+1])
					{
						tf=0;
						break;
					}
				
			if(tf)
			{
				r=i+1;
				break;
			}
		}
	if(r!=0)
		break;

	} while (next_permutation(all(v)));

	for(int i=0;i<r;i++)
		{
			P[i]=v[i].F;
			Q[i]=v[i].S;
		}
	

	return r;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:5:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    5 | #define F first
sorting.cpp:50:14: note: in expansion of macro 'F'
   50 |    P[i]=v[i].F;
      |              ^
sorting.cpp:6:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    6 | #define S second
sorting.cpp:51:14: note: in expansion of macro 'S'
   51 |    Q[i]=v[i].S;
      |              ^
sorting.cpp:55:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   55 |  return r;
      |         ^
sorting.cpp:12:46: warning: unused parameter 'X' [-Wunused-parameter]
   12 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:12:55: warning: unused parameter 'Y' [-Wunused-parameter]
   12 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -