답안 #1081571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081571 2024-08-30T07:39:13 Z Trumling 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 856 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;
ll n;
 
 
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) 
{ 
    n=N;
    ll pos[N];
    for(int i=0;i<N;i++)
        pos[S[i]]=i;
 
 	vector<pair<ll,ll>>v;
    for(int i=0;i<N;i++)
    {
     	v.pb({pos[i],i});
        swap(S[pos[i]],S[i]);
        pos[S[pos[i]]]=pos[i];
        pos[i]=i;
 
    }
             
 for(int i=0;i<v.size();i++)
             {
               P[i]=v[i].F;
               Q[i]=v[i].S;
             }
 	assert(v.size()>M);
      return v.size();
        
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |     for(int i=0;i<N;i++)
      |     ^~~
sorting.cpp:21:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   21 |   vector<pair<ll,ll>>v;
      |   ^~~~~~
sorting.cpp:31: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]
   31 |  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:33:26: note: in expansion of macro 'F'
   33 |                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:34:26: note: in expansion of macro 'S'
   34 |                Q[i]=v[i].S;
      |                          ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from sorting.cpp:2:
sorting.cpp:36:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   assert(v.size()>M);
      |          ~~~~~~~~^~
sorting.cpp:37:20: 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]
   37 |       return v.size();
      |              ~~~~~~^~
sorting.cpp:14:46: warning: unused parameter 'X' [-Wunused-parameter]
   14 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                          ~~~~^~~
sorting.cpp:14:55: warning: unused parameter 'Y' [-Wunused-parameter]
   14 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                   ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 856 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -