답안 #641698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
641698 2022-09-17T13:08:30 Z Benmath 정렬하기 (IOI15_sorting) C++14
0 / 100
3 ms 340 KB
#include<bits/stdc++.h>
#include "sorting.h"
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
   int n=N;
   int bro=0;
   int R=n;
   for(int i=0;i<=(n-2);i++){
      swap(S[X[i]],S[Y[i]]);
      int loc=i;
      for(int j=n-2;j>i;j--){
         if(X[j]==loc){
            loc=Y[j];
         }else{
            if(Y[j]==loc){
               loc=X[j];
            }
         }
      }
      if(loc==i){
         int bro=0;
         while(bro<1e9){
            bro++;
         }
      }
      int loc1=-1;
      for(int j=0;j<n;j++){
         if(S[j]==i){
            loc1=j;
            break;
         }
      }
      if(loc1!=loc){
         P[i]=loc1;
         Q[i]=loc;
      }else{
         P[i]=loc1;
         Q[i]=loc1;
      }
   }
    return R;
}
/*
int main(){
   
}
*/

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:21:14: warning: declaration of 'bro' shadows a previous local [-Wshadow]
   21 |          int bro=0;
      |              ^~~
sorting.cpp:6:8: note: shadowed declaration is here
    6 |    int bro=0;
      |        ^~~
sorting.cpp:6:8: warning: unused variable 'bro' [-Wunused-variable]
sorting.cpp:4:39: warning: unused parameter 'M' [-Wunused-parameter]
    4 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -