답안 #833884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
833884 2023-08-22T09:19:27 Z Ellinor 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 340 KB
    //#include<bits/stdc++.h>
    #include <iostream>
    #include <vector>
    #include <queue>
    #include <string>
    #include <cmath>
    #include <cstdlib>
    #include <set>
    #include <iomanip>
    #include <limits>
    #include <map>
    #include <assert.h>
    #include <algorithm>
    #include <list>
    #include <iterator>
    #include <fstream>
    #include <random>
    #include <unordered_map>
    #include <array>
     
    #define rep(i,a,b) for (int i = (a); i < b; i++)
    #define pb push_back
    #define all(x) x.begin(), x.end()
    typedef long long ll;
    //typedef pair<int, int> pii;
     
    // fast
     
    #include "sorting.h"
     
    int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
    {
        // P[0] = 0;
    	// Q[0] = 0;
     
        int R = 0;
        rep(i,2,N)
        {
            if (S[i] != i) 
            {
                R++;
                //
            }
        }
     
        if (Y[0] == 0)
        {
            if (S[0] != 0) R++;
        }
        else
        {
            if (R % 2 == 0) if (S[0] != 0) R++;
            else if (S[1] != 0) R++;
            //
        }
     
    	return R;
    }
     
    // 20p, 0, 0
    // 16p, 0, 1, first all else, then 1 -> 1 (if needed)

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:52:16: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   52 |             if (R % 2 == 0) if (S[0] != 0) R++;
      |                ^
sorting.cpp:31:43: warning: unused parameter 'M' [-Wunused-parameter]
   31 |     int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                       ~~~~^
sorting.cpp:31:50: warning: unused parameter 'X' [-Wunused-parameter]
   31 |     int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                              ~~~~^~~
sorting.cpp:31:68: warning: unused parameter 'P' [-Wunused-parameter]
   31 |     int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                                ~~~~^~~
sorting.cpp:31:77: warning: unused parameter 'Q' [-Wunused-parameter]
   31 |     int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                                         ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -