답안 #851247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
851247 2023-09-19T06:35:44 Z 12345678 정렬하기 (IOI15_sorting) C++17
20 / 100
1000 ms 15032 KB
#include "sorting.h"
#include <bits/stdc++.h>
 
using namespace std;

const int nx=2e3+5;
int dp[nx][nx], cnt(0);
vector<pair<int, int>> ans;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    for (int i=0; i<N; i++) dp[0][i]=S[i];
    for (int i=1; i<=N; i++)
    {
        for (int j=0; j<N; j++) dp[i][j]=dp[i-1][j];
        swap(dp[i][X[i-1]], dp[i][Y[i-1]]);
        ans.clear();
        vector<int> l(N);
        for (int j=0; j<N; j++) l[j]=dp[i][j];
        for (int j=0; j<N; j++) for (int k=j+1; k<N; k++) if (l[k]==j) ans.push_back({j, k}), swap(l[k], l[j]);
        if (ans.size()<=i) 
        {
            while (ans.size()<i) ans.push_back({0, 0});
            break;
        }
    }
	cnt=ans.size();
    for (int i=0; i<cnt; i++) P[i]=ans[i].first, Q[i]=ans[i].second;
    return cnt;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:20:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if (ans.size()<=i)
      |             ~~~~~~~~~~^~~
sorting.cpp:22:30: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |             while (ans.size()<i) ans.push_back({0, 0});
      |                    ~~~~~~~~~~^~
sorting.cpp:26:14: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   26 |  cnt=ans.size();
      |      ~~~~~~~~^~
sorting.cpp:10:39: warning: unused parameter 'M' [-Wunused-parameter]
   10 | int findSwapPairs(int N, int S[], 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 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
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 1 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1002 ms 15032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1002 ms 15032 KB Time limit exceeded
2 Halted 0 ms 0 KB -