제출 #1355068

#제출 시각아이디문제언어결과실행 시간메모리
1355068yogesh_saneSorting (IOI15_sorting)C++20
컴파일 에러
0 ms0 KiB
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    vector<int>pos(N);
    for(int i = 0; i < M; i++){
        swap(S[X[i]], S[Y[i]]);            
        iota(pos.begin(), pos.end(), 0);
        for(int j = i+1; j < M; j++)
            swap(pos[X[j]], pos[Y[j]]);
        for(int j = 0; j < N; j++){
            if(S[pos[j]] != j){
                int k = find(S, S+N, j)-S;
                P[i] = pos[j];
                Q[i] = k;
                swap(S[pos[j]], S[k]);
                break;
            }
        }
    }
    return M;
}

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

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:2:5: error: 'vector' was not declared in this scope
    2 |     vector<int>pos(N);
      |     ^~~~~~
sorting.cpp:2:12: error: expected primary-expression before 'int'
    2 |     vector<int>pos(N);
      |            ^~~
sorting.cpp:4:9: error: 'swap' was not declared in this scope
    4 |         swap(S[X[i]], S[Y[i]]);
      |         ^~~~
sorting.cpp:5:14: error: 'pos' was not declared in this scope
    5 |         iota(pos.begin(), pos.end(), 0);
      |              ^~~
sorting.cpp:5:9: error: 'iota' was not declared in this scope
    5 |         iota(pos.begin(), pos.end(), 0);
      |         ^~~~
sorting.cpp:10:25: error: 'find' was not declared in this scope
   10 |                 int k = find(S, S+N, j)-S;
      |                         ^~~~