답안 #1075133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1075133 2024-08-25T18:55:29 Z ArthuroWich 정렬하기 (IOI15_sorting) C++17
20 / 100
2 ms 600 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
int findSwapPairs(int n, int p[], int M, int X[], int Y[], int P[], int Q[]) {
    vector<pair<int, int>> ans;
    int d = 0;
    for (int i = n-1; i >= 0; i--) {
        if (p[i] == i) {
            continue;
        }
        while(p[i] != i) {
            int j = p[i];
            ans.push_back({i, j});
            swap(p[i], p[j]);
            bool f = 1;
            for (int l = 0; l < n; l++) {
                if (p[l] != l) {
                    f = 0;
                }
            }
            if (f) {
                break;
            }
            int x = X[d], y = Y[d];
            swap(p[x], p[y]);
            d++;
        }
    }
    for (int i = 0; i < ans.size(); i++) {
        P[i] = ans[i].first;
        Q[i] = ans[i].second;
    }
    return ans.size();
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~
sorting.cpp:33:20: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   33 |     return ans.size();
      |            ~~~~~~~~^~
sorting.cpp:4:39: warning: unused parameter 'M' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int p[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 380 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Incorrect 0 ms 348 KB Integer parameter [name=R] equals to 152, violates the range [0, 150]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 380 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Incorrect 0 ms 348 KB Integer parameter [name=R] equals to 152, violates the range [0, 150]
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -