답안 #1018539

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018539 2024-07-10T06:35:06 Z huutuan 정렬하기 (IOI15_sorting) C++14
0 / 100
3 ms 604 KB
#include "sorting.h"

#include <bits/stdc++.h>

using namespace std;

int a[200010];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
   iota(a, a+N, 0);
   // for (int i=M-1; i>=0; --i) swap(a[X[i]], a[Y[i]]);
   for (int i=0; i<M; ++i){
      P[i]=Q[i]=0;
      // swap(a[X[i]], a[Y[i]]);
      swap(S[X[i]], S[Y[i]]);
      for (int j=0; j<N; ++j) if (a[j]!=S[j]){
         int k=find(S, S+N, a[j])-S;
         P[i]=j; Q[i]=k;
         swap(S[j], S[k]);
         break;
      }
   }
   for (int j=0; j<N; ++j) assert(S[j]==j);
   return M;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:17:34: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   17 |          int k=find(S, S+N, a[j])-S;
      |                ~~~~~~~~~~~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 Correct 1 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 Runtime error 1 ms 376 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 Runtime error 3 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 604 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -