답안 #572445

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572445 2022-06-04T11:45:45 Z MohamedFaresNebili 정렬하기 (IOI15_sorting) C++14
20 / 100
8 ms 468 KB
#include <bits/stdc++.h>
#include "sorting.h"
#include <ext/pb_ds/assoc_container.hpp>

        using namespace std;
        using namespace __gnu_pbds;

        using ll = long long;
        using ii = pair<int, int>;
        using vi = vector<int>;

        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define all(x) (x).begin(), (x).end()

        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

        int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
            for(int l = 0; l < M; l++) {

                bool ok = 1;
                for(int i = 0; i < N - 1; i++)
                    if(S[i] > S[i + 1]) {
                        ok = 0; break;
                    }
                if(ok) return l;

                int i = X[l], j = Y[l];
                swap(S[i], S[j]);

                for(int i = 0; i < N; i++) {
                    if(S[i] != i) {
                        P[l] = i; break;
                    }
                }

                for(int i = 0; i < N; i++) {
                    if(S[i] == P[l]) {
                        Q[l] = i; break;
                    }
                }

                swap(S[P[l]], S[Q[l]]);
            }
            return M;
        }

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:35:25: warning: declaration of 'i' shadows a previous local [-Wshadow]
   35 |                 for(int i = 0; i < N; i++) {
      |                         ^
sorting.cpp:32:21: note: shadowed declaration is here
   32 |                 int i = X[l], j = Y[l];
      |                     ^
sorting.cpp:41:25: warning: declaration of 'i' shadows a previous local [-Wshadow]
   41 |                 for(int i = 0; i < N; i++) {
      |                         ^
sorting.cpp:32:21: note: shadowed declaration is here
   32 |                 int i = X[l], j = Y[l];
      |                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -