제출 #572445

#제출 시각아이디문제언어결과실행 시간메모리
572445MohamedFaresNebili정렬하기 (IOI15_sorting)C++14
20 / 100
8 ms468 KiB
#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;
        }

컴파일 시 표준 에러 (stderr) 메시지

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];
      |                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...