답안 #1081588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081588 2024-08-30T07:48:32 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 arr[], int M, int X[], int Y[], int P[], int Q[]) 
{ 
    int pos[N];
    for(int i=0;i<N;i++)
    {
      pos[arr[i]]=i;
    }
        
 
 	vector<pair<ll,ll>>v;
    for(int i=0;i<N;i++)
    {
     	v.pb({pos[i],i});
        swap(arr[pos[i]],arr[i]);
        pos[arr[pos[i]]]=pos[i];
        pos[i]=i;
 
    }
    
 assert(is_sorted(arr,arr+N));
 for(int i=0;i<v.size();i++)
             {
               P[i]=v[i].F;
               Q[i]=v[i].S;
             }
			
    return v.size();
        
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i=0;i<v.size();i++)
      |              ~^~~~~~~~~
sorting.cpp:5:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
    5 | #define F first
sorting.cpp:36:26: note: in expansion of macro 'F'
   36 |                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:37:26: note: in expansion of macro 'S'
   37 |                Q[i]=v[i].S;
      |                          ^
sorting.cpp:40:18: warning: conversion from 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   40 |     return v.size();
      |            ~~~~~~^~
sorting.cpp:14:41: warning: unused parameter 'M' [-Wunused-parameter]
   14 | int findSwapPairs(int N, int arr[], int M, int X[], int Y[], int P[], int Q[])
      |                                     ~~~~^
sorting.cpp:14:48: warning: unused parameter 'X' [-Wunused-parameter]
   14 | int findSwapPairs(int N, int arr[], int M, int X[], int Y[], int P[], int Q[])
      |                                            ~~~~^~~
sorting.cpp:14:57: warning: unused parameter 'Y' [-Wunused-parameter]
   14 | int findSwapPairs(int N, int arr[], int M, int X[], int Y[], int P[], int Q[])
      |                                                     ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 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 -